I'm trying to upload a photo to a venue on foursquare.
This my code :
$image = "/assets/uploads/image/test.jpg";
$fields = json_encode(array("photo" => "@".$image));
$url = "https://api.foursquare.com/v2/photos/add?oauth_token=<my-oauth-token>&v=20160609&venueId=<my-venue-id>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20000);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
//curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($s));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: image/jpeg"));
$response = curl_exec($ch);
echo $response; exit;
and response
{"meta":{"code":400,"errorType":"other","errorDetail":"Missing file upload","requestId":"57d6abf3498e0eb7f4639fa1"},"notifications":[{"type":"notificationTray","item":{"unreadCount":12}}],"response":{}}
Obviously I added the customs token and venue id. I tried to add a tip via curl, no problem. I use codeigniter and php5.4
More info on foursquare API https://developer.foursquare.com/docs/photos/add
Thanks for the help!