通过graph api将照片发布到朋友墙
我正在尝试使用新的图形 API 将照片发布到朋友墙上。为此,我有以下代码:
$attachment = array(
'message' => 'Posted a photo',
'source' => '@' . realpath(PATH_TO_MY_PHOTO)
);
$facebook->setFileUploadSupport(true);
$facebook->api('/'.$id_friend.'/feed?access_token='.$access_token, 'post', $attachment);
问题是图片未上传。我的意思是,它只发布消息,没有任何图片。如果我尝试在当前用户墙上发帖,这也不起作用。
有谁知道如何实现这一目标?谢谢。
ps我只请求publish_stream权限
I'm trying to post a photo to one of friends wall using the new graph api. For this I have the following code:
$attachment = array(
'message' => 'Posted a photo',
'source' => '@' . realpath(PATH_TO_MY_PHOTO)
);
$facebook->setFileUploadSupport(true);
$facebook->api('/'.$id_friend.'/feed?access_token='.$access_token, 'post', $attachment);
The problem is that the picture is not uploaded. I mean, it only post the message without any picture. This does not work either if I try to post on the current user wall.
Does anyone have any idea on how to achieve this ? Thanks.
p.s. I'm requesting only publish_stream permission
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了将 poto 发布到用户墙上,就像发布照片而不是流故事一样,
您可以发布到此处:
有关更多信息,请访问 facebook 的 graph api 照片文档。
In order to post a poto to a users wall, as in publishing a photo and not a stream story,
you can post to here:
for more information visit facebook's graph api photo documentation.
您应该将“来源”替换为“图片”。
$imagepath='http://site.com/pic.jpg';
$附件=数组(
'消息' => '发布了一张照片',
'图片' => $图像路径
);
$facebook->setFileUploadSupport(true);
$facebook->api('/'.$id_friend.'/feed?access_token='.$access_token, 'post', $attachment)
您可以选择添加更多字段。欲了解更多详情:
https://developers.facebook.com/docs/reference/api/post/
You should replace "source" with "picture".
$imagepath='http://site.com/pic.jpg';
$attachment = array(
'message' => 'Posted a photo',
'picture' => $imagepath
);
$facebook->setFileUploadSupport(true);
$facebook->api('/'.$id_friend.'/feed?access_token='.$access_token, 'post', $attachment)
You can optionally add some more fields. for more details:
https://developers.facebook.com/docs/reference/api/post/