从应用程序将照片上传到Facebook相册

从应用程序将照片上传到Facebook相册

问题描述:

我已经使用了

'req_perms' => 'publish_stream,status_update'

我得到的错误是


致命错误:未捕获CurlException:26:在第589行的facebook.php中创建formpost数据失败

Fatal error: Uncaught CurlException: 26: failed creating formpost data thrown in facebook.php on line 589

我的上传代码:

$facebook->setFileUploadSupport(true);
$args = array('message' => 'My Friend\'s');
$args['image'] = '@' . realpath('http://mysite/img/img.jpg');
$data = $facebook->api('/me/photos', 'post', $args);
print_r($data);

我只想将照片上传到现有的相册或已创建的相册。工作代码是什么?

I just want to upload the photo to an existing album or already created album. What would working code be?

另一个代码

$photo_details = array('message'=>$_REQUEST['arttitle'],'source'=> '@' . realpath( $_FILES[file]tmp_name]));
$facebook->api('/me/photos','POST',$photo_details);

结果


致命错误:未捕获OAuthException:(#324)需要在第522行的facebook.php中抛出上传文件

Fatal error: Uncaught OAuthException: (#324) Requires upload file thrown in facebook.php on line 522

我尝试过其他

我尝试过下面的代码,它的工作完美。

I tried the code below, and it worked perfectly.

$facebook->setFileUploadSupport(true);

$album_details = array(
    'message'=> 'album description goes here',
    'name'=> 'album name goes here'
);
$create_album = $facebook->api('/me/albums', 'post', $album_details);

// Upload a picture
$photo_details = array(
    'message'=> 'photo description'
);
$photo_details['image'] = '@' . realpath('/the/path/to/your/image.jpg');
$upload_photo = $facebook->api('/'.$create_album['id'].'/photos', 'post', $photo_details);

echo $upload_photo['id']; // The id of your newly uploaded pic.