views:

76

answers:

2

Hello. I have an application that uses the old Facebook API but now I'm migrating it. The application works good until I try to upload a photo.

I knew how to do it in the old way, but now... I'm in troubles.

This is the way I used to do it:

$args = array ( 'method' => 'photos.upload', 'v' => $ver, 'api_key' => $key, 'uid' => $uid, 'call_id' => $cid, 'format' => 'XML', 'caption' => $caption );

signRequest($args, $sec);
$args[basename($file)] = '@' . realpath($file);

$ch = curl_init();
$url = 'http://api.facebook.com/restserver.php?method=photos.upload';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);

Any ideas??

Thanks

A: 

The API url starts with https:// not http://. That could be the issue.

Sarfraz
A: 

I found the solution here:

http://stackoverflow.com/questions/3019501/uploading-a-picture-to-facebook

There is shown how to use the new Facebook Graph API with the PHP Curl function and a valid session token.

Jean Paul

related questions