2012年10月19日 星期五

透過程式在粉絲對粉絲團文章按讚


主要要要取得文章在粉絲團上的ID

        var accessToken = Session["AccessToken"].ToString();
        var client = new FacebookClient(accessToken);

        dynamic args = new Dictionary();
        args["id"] = PostFeedID;  

取得後我們就能使用程式對粉絲團文章按讚

client.Post("/likes", args);//按讚
client.Delete("/likes", args);//收回讚

至於PostFeedID哪裡來,這就是我們自己也要透過程式去發佈文章,才能夠自動取得文章ID存下來,在實做介面讓使用者能對該文章按讚

取得粉絲團某篇文章中的讚(json型態)
https://graph.facebook.com/248591291930622_372364039507601/likes

javascript 作法 

FB.api(post_id + '/likes', action, { access_token: user_accessToken }, function(response) {
  alert(response);
}); 

 
參考資料
http://stackoverflow.com/questions/4534975/like-posts-over-facebook-graph-api
View who likes object with id $id:
$this->getFacebook()->api("/$id/likes", 'get');
Add like to object with id $id:
$this->getFacebook()->api("/$id/likes", 'post');
Remove like from object with id $id:
$this->getFacebook()->api("/$id/likes", 'delete');
Make sure you have the publish_stream permission to post and delete likes.

關鍵字
facebook like post api
facebook like post

其他參考
如何取得粉絲團文章單一狀態?
在文章的發文日期中複製其連結即為該文章的資料 
http://www.facebook.com/xxx.com.tw/posts/123596604456875

沒有留言:

張貼留言