2012-08-27 25 views
1

我希望我的網站比目前具有更好的fb集成。截至目前,我使用以下代碼發佈消息/鏈接到給定用戶的時間表。PHP將自定義應用程序操作發佈到時間線

$attachment = array('message' => 'Predicted the '.ucwords($winning_team_short).' to beat the '.ucwords($losing_team_short).' on '.ordSuffix($new_date_format).'', 
      'caption' => 'Sportannica - Online Sports Encyclopedia', 
      'name' => 'How will your predictions pan out?', 
      'link' => 'http://www.sportannica.com/games/'.$league.'/'.$game.'/predictions', 
      'description' => ''.ucwords($winning_team_short).' ('.$winning_score.') '.ucwords($losing_team_short).' ('.$losing_score.')', 
      'picture' => 'http://www.sportannica.com'.$path.''.$winning_team.'.png' 
     ); 

     $facebook->api('/me/feed/', 'post', $attachment); 

我想要一個更好的方法,雖然...一個將消息發佈到用戶的時間軸,就像Spotify這樣的應用程序的方式。

當我打開圖形儀表板時,我定義了幾個自定義動作和對象。一個行動是「預測」。我想讓它的內容是:「。$ fb_user_name。」已經預測到「。$ winning_team。」擊敗「。$ game_date。」上的「。$ losing_team。」。

我對fb api比較陌生,所以當談到這種材料時我有點失落。我知道Spotify的方法使用自定義操作,所以我知道我在正確的道路上。任何人都可以發佈一些示例php代碼發佈消息的方法,該消息利用自定義操作和對象到用戶的時間軸上?

謝謝,

蘭斯

回答

1

實施例:

在分批查詢使用PHP SDK 3.1.1 /,其他查詢中移除。

$queries = array(
     array('method' => 'POST', 'relative_url' => '/me/anotherfeed:view?feed=http://anotherfeed.com/?fbid='.$thepage[id].'') 
     // any other api calls needed, this is a batch request for performance. 
    ); 
    try { 
$postResponseA = $facebook->api('?batch='.json_encode($queries), 'POST'); 
    } catch (FacebookApiException $e) { 
    //echo 'AF error: '.$e.''; 
    } 
    $actions=json_decode($postResponseA[0][body], true); 

的柱的上方在破碎至4部分

命名空間anotherfeed:

行動view?

對象feed

URLhttp://anotherfeed.com/?fbid='.$thepage[id].'

這將產生「用戶觀看的另一個頻道無論頻道」


的操作取決於OG Meta標籤在頁面的頭,填補了動作後。

實施例的標籤:

<meta property="og:title" content="SecurityNewsDaily" />  
<meta property="og:description" content="SecurityNewsDaily on Another Feed, Feeding on the best of Facebook, one page at a time." /> 
<meta property="og:type" content="anotherfeed:feed" /> 
<meta property="og:image" content="https://graph.facebook.com/146893188679657/picture?type=large" /> 
<meta property="og:site_name" content="AnotherFeed" /> 
<meta property="fb:app_id" content="135669679827333" /> 
<meta property="fb:admins" content="732484576" /> 
<meta property="og:url" content="http://anotherfeed.com/index.php?fbid=146893188679657" /> 
<meta property="og:restrictions:age" content="13+"/> 
+1

哦~~。那麼,在$ winning_team的頁面中,我需要打開那些打開的圖標記? – Lance

+0

是的,您需要在您發佈的任何頁面上打開圖標。 –

+1

我有以下代碼。並沒有發生。 – Lance

相關問題