Add an image to a tip on Foursquare [PHP]
I am trying to attach an image to a tip on Foursquare.
This is my code:
// Add photo to the tip
$photo_raw = file_get_contents( $imag ); //$imag is the url to the image
$request3 = "https://api.foursquare.com/v2/photos/add";
$data3 = array( "tipId" => $tip_id, "photo" => $imag, 'oauth_token' =>
$row[0], 'v' => $version );
$options = array(
'http' => array(
'header' => "Content-type: image/jpeg\r\n",
'method' => 'POST',
'content' => http_build_query($data3),
),
);
$context = stream_context_create($options);
$result3 = file_get_contents($request3, false, $context);
var_dump( $result3 );
I have tried posting $photo_raw as well. It always returns bool(false).
In the logs I've seen
[Tue Sep 10 03:01:13 2013] [warn] [client 46.246.156.192] mod_fcgid:
stderr: PHP Warning:
file_get_contents(https://api.foursquare.com/v2/photos/add)
[function.file-get-contents]: failed to open stream: HTTP request failed!
HTTP/1.1 400 Bad Request
[Tue Sep 10 03:01:13 2013] [warn] [client 46.246.156.192] mod_fcgid:
stderr: in /var/www/vhosts/travelmint.gr/httpdocs/apps/fsq/index.php on
line 166
Shouldn't it work like that? What is the mistake? :/
No comments:
Post a Comment