2009
十月
27

facebook API心得手扎-stream.publish

分類 分類於《工作五四三》    編輯

facebook於上周六公佈消息,自今年12月20日開始將不再支援下列的feed API:

» Template bundles. You should start using stream attachments with the stream publishing methods instead.
» feed.publishUserAction
» feed.publishTemplatizedAction
» Facebook.showFeedDialog and FB.Connect.showFeedDialog
» Publisher stories that use templates (please transition them to use stream attachments).
» Feed forms that reference the feedStory form and the multiFeedStory form.
» One-line stream stories.

這也意味著要發佈訊息到自己或朋友的頁面,得要改用新的stream.publish函式。

昨天嘗試做了一下:

 $message = ‘這是訊息’; //(A)
 $attachment = array(
  』name』=>』附件主要標題』, //(B)
  』href』=>』http://apps.facebook.com/xxxxxxx/』,
  』description』=>』叭啦叭啦叭啦叭啦叭啦叭啦一長串的說明文字』, //(C)
  』media』 => array(
   array(
    』type』 => 『image』,
    』src』 => 『http://farm3.static.flickr.com/2643/3979186255_1bd46aa15b.jpg』,
    』href』 => 『http://www.flickr.com/photos/cupidtsao/sets/72157622512555988/』
   )
  )
 );
 $action_links = array(
  array(
   』text』=> 『動作超連結』, //(D)
   』href』=> 『http://apps.facebook.com/xxxxxxx/yyyy.php』
  )
 );
 try {
  $facebook->api_client->stream_publish($message, $attachment, $action_links, NULL, 』);
 } catch(Exception $e) {
 switch ($e->getCode()) {
  case 200:
   echo ‘警告!您必須先開放發佈資訊的權限。’;
   echo ‘<fb:prompt-permission perms=』publish_stream』>允許張貼您的作品</fb:prompt-permission>’;
   break;
  default:
   echo ‘<br>Error message: ‘.$e->getMessage().’ Error code:’.$e->getCode().’<p>’;
 }
}

引用連結 引用連結 http://kuso.us/blog/wp-trackback.php?p=164

3 Responses to “facebook API心得手扎-stream.publish”

在這裡發表您的留言 »