开发者

java access to like data

Specifically, I am working on a class that I can call that would have a method I can pass an id (the ID of a companies page) and would want the number for the like_count returned.

I walked through the steps to get what I thought was a no expire access_token (used the scope=offline_access).

a) I created an API and got the 'APP id' and the 'App Secret'

b) Then I make a request to the URL https to graph.facebook.com/oauth

to get a code using the following (has example data)

?authorize?client_id={USED_APP_ID}&redirect_uri={USED_A_REGISTERED_LANDING_PAGE}

This produced a code response {THE_CODE_RESPONSE}

c) Then made a request to https to graph.facebook.com/oauth/

to get an access_token开发者_运维技巧 using the following (also example)

?access_token?client_id={USED_APP_ID}&redirect_uri={USED_A_REGISTERED_LANDING_PAGE}&scope=offline_access&client_secret={USED_APP_SECRET}&code={THE_CODE_RESPONSE}

I did get an access_token {THE_ACCESS_TOKEN} .

The above looks to work.

What I was trying to do was to get an access token that I can use to make requests to the graph API to get likes

https://graph.facebook.com/{ID}/likes?access_token={THE_ACCESS_TOKEN}

A couple of questions:

1) How to get {ID} for a company? Is the id from a:

SELECT domain_id FROM domain WHERE domain_name='www.facebook.com'

? Or is there another means?

2) Am I on the correct path with https to graph.facebook.com/{ID}/?access_token={THE_ACCESS_TOKEN} ?

In the end what I would like to do is have a means to get the needed detail (is that some ID) to be able to find the like_count given a domain name.

Did I provide enough details or information for my question?


Think easy. If you really just want the like_count for

a) a facebook (business) page b) a website

then you don't have to use the any Auth or Apps. Just call the graph api and extract the 'like' (case a) or shares (case b) from the json object!

For example:

a) http://graph.facebook.com/yahoo
b) http://graph.facebook.com/http://www.yahoo.com

If you need the id of a facebook page, just extract the 'id' from the json object. There are afaik no id's for webpages!

Code example:

<?php
$url_or_id = implode(",",$permalinks);
$handle = @file_get_contents("https://graph.facebook.com/?ids=".urlencode($url_or_id));
$handle = json_decode($handle, true);

$likes = $handle['likes']; // case a
$shares = $handle['shares']; // case b
$id = $handle['id']; // id of facebook page/account
?>


developers.facebook.com -> tools -> Graph API Explorer -> select id checkbox in left bottom corner. I think you might need this value to get likes count.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜