从应用程序将照片上传到Facebook相册 [英] Upload photos to Facebook Album from an app
本文介绍了从应用程序将照片上传到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.
这篇关于从应用程序将照片上传到Facebook相册的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文