2011-09-14 19 views
0

我拼命寻找图像附件php api饲料为我的Facebook应用程序。寻找图像附件php API的feed.publish

基本上我试图做的是发送一个图像附件,以及一个自动的“张贴到朋友墙”行动。

它背后的想法是,用户发送一个“虚拟汉堡”给他们的朋友墙,并给他们提供折扣的消息。

这是成功发送消息的代码片段,但无法使附件正常工作。

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>"; 

回答

0

我认为有两种方法将图像附加到墙贴。

第一个是定义目标页面中的meta og:图像并将链接发布到好友墙。 Facebook将查询目标并获取在墙上显示的Open Graph信息。你可以用Facebook Debugger进行测试。

元属性应该是这样的:

<meta property="og:image" content="http://url.to/image" /> 

您还可以定义标题,说明等

其他开放式图形属性附加图像的第二种方法后是在Graph API调用中包含图片参数。在你的代码只定义了一些参数(链接,名称,描述...),但你还可以发送图片,标题,消息...

所以,你的API调用可能是这样的:

$params = array( 'access_token' => '', 
        'message' => '', 
        'link'  => '', 
        'picture' => '', 
        'name'  => '', 
        'caption' => '', 
        'description' => '' 
); 

$wallPost = $facebook->api('/'.$to.'/feed', 'post', $params);