使用facebook php sdk在左侧发布照片并在右侧发表评论[关闭]

问题描述:

I am working on a app, it almost nearing completion. i want to post a image related to my app with comment on the users wall when user uses my app. i have seen so many apps on FB, which post image with comment, just like a invitation card, so that users friends can also use it .so can anyone help me on this

thanks in advance

我正在开发一个应用程序,它几乎接近完成。 我希望在用户使用我的应用时发布与我的应用相关的图像并在用户墙上发表评论。 我在FB上看到了很多应用程序,它们发布评论的图像,就像邀请卡一样,这样用户朋友也可以使用它。所以任何人都可以帮我这个 p>

谢谢 提前 p> div>

First things first, make sure the following permission is obtained:

publish_stream

Now, assuming you have created a $facebook object using the SDK, you can then post to the stream including a picture on the lefthand side:

$attachment = array
(
'access_token'=>$facebook->getAccessToken(),
'message' => 'This is the message',
'name' => 'NAME',
'caption' => 'This is my caption:',
'description' => 'This is the description',
'picture' => 'http://www.facebookanswers.co.uk/img/misc/iq.jpg'
);
$result = $facebook->api($this->id.'/feed/','post',$attachment);

The message field can be omitted if you want. I have included it so that at least you know it is there.

You need to change the contents of the fields to suit your needs, but hopefully you get the picture.