2011-09-14 18 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);