通过图形api将照片发布到朋友墙


post photo to friend wall through 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);

问题是图片没有上传。我是说,它只发了一条信息,没有图片。如果我试图在当前用户墙上发布,这也不起作用。

有人知道如何实现这一点吗?谢谢。

注。我只请求publish_stream权限

为了在用户墙上发布照片,就像发布照片而不是流故事一样,你可以在这里发帖:

http://graph.facebook.com/ALBUM_ID/photos.

欲了解更多信息,请访问facebook的图形API照片文档。

你应该把"source"换成"picture"

imagepath美元= ' http://site.com/pic.jpg ';

$attachment = array('message' => '张贴照片','picture' => $imagepath

);

facebook -> setFileUploadSupport(真正的);facebook -> api ('/' id_friend美元。"/饲料? access_token ="。$access_token, 'post', $attachment)

您可以选择添加更多字段。欲知详情:https://developers.facebook.com/docs/reference/api/post/