我正在拼命寻找图像附件php api feed为我的facebook应用程序。
基本上我想做的是发送一个图像附件,以及一个自动"发布到朋友墙"的动作。
其背后的想法是,用户发送一个"虚拟汉堡"到他们的朋友墙,并提供一条信息,提供折扣。
这是成功发送消息的代码片段,但是我无法使附件工作。
if($_REQUEST['friend_1']!='' && $_REQUEST['friend_1']!="Start typing a friend's name") {
try {
$fql1 = "select name from user where uid=" . $_REQUEST['friend_1'];
$param1 = array(
'method' => 'fql.query',
'query' => $fql1,
'callback' => ''
);
$fqlResult1 = $facebook->api($param1);
$friend_1_name = $fqlResult1[0]['name'];
$statusUpdate = $facebook->api('/'.$_REQUEST['friend_1'].'/feed', 'post', array('link' => $fanpageURL, 'name' => 'Have a virtual Unity Burger.', 'description' => " ".$user_name." just sent you a virtual Unity Burger. If you would rather have the real thing then come add your name on the Unity list and we will give you a 20% discount on your next visit and an exclusive Unity keyring.", 'properties' => '', 'cb' => ''));
} catch (FacebookApiException $e) {
//echo "Notification not send to user ".$fqlResult1[0]['name']."<br>";
我认为有两种方法可以将图片附加到墙上。
第一个是在目标页面中定义meta og:图像,并将链接发布到好友墙。Facebook将查询目标并抓取显示在墙上的Open Graph信息。你可以用Facebook调试器来测试。
meta属性应该是这样的:
<meta property="og:image" content="http://url.to/image" />
您还可以定义其他Open Graph属性,如标题,描述等。
将图像附加到帖子的第二种方法是在Graph API调用中包含picture参数。在你的代码中,你只定义了一些参数(链接,名称,描述…),但你也可以发送图片,标题,消息…
所以你的API调用可以像这样:$params = array( 'access_token' => '',
'message' => '',
'link' => '',
'picture' => '',
'name' => '',
'caption' => '',
'description' => ''
);
$wallPost = $facebook->api('/'.$to.'/feed', 'post', $params);