Is it possible to read Facebook's wall posts from a console app using facebooksdk on codeplex?
I need to read the posts on Microsoft's facebook wall.
Thank you
Easiest path: https://graph.facebook.com/microsoft/feed?access_token={appID}|{appSecret}. Additionally, if you have a user's access token there, it'll work as well. Since this data is public, we only need to know what app is accessing it, so either kind of token will work.
I'm not familiar with the facebooksdk on codeplex, but I assume it can help you generate access tokens. Once you have an access token, simply curl https://graph.facebook.com/microsoft/feed?access_token=YOUR_ACCESS_TOKEN to get the wall of the page.
You can directly hit up https://graph.facebook.com/microsoft/posts to read their wall posts
Check out the graph API explorer https://developers.facebook.com/tools/explorer
to play around with what is exposed in the facebook api
If you're just accessing this one fan page, you have the options of using Facebook PowerShell Module, this is
PS C:\Windows\system32> Get-FBAssociation -id 20528438720 -type Statuses
id : 10150289130443721
message : Friday Question: How will you be spending your last few weeks of summer?
likes : {#{id=167736043271797; name=Microsoft Tag Master}, #{id=100001944243060; name=Rahul Bhatt}, #{id=1520665678; name=Khair Eddin Réguiég}, #{id=100001258437657
; name=Ritesh Raj}...}
comments : {#{id=10150289130443721_18321628; message=planking; likes=3; from=; created_time=2011-08-26T16:47:05+0000}, #{id=10150289130443721_18321629; message=Hooking
up with girls!; likes=2; from=; created_time=2011-08-26T16:47:07+0000}, #{id=10150289130443721_18321630; message=looking for a new laptop!; likes=1; from=;
created_time=2011-08-26T16:47:07+0000}, #{id=10150289130443721_18321634; message=PLAYING MY XBOXXXX; likes=2; from=; created_time=2011-08-26T16:47:18+0000}
...}
from : #{id=20528438720; name=Microsoft; category=Company}
updated_time : 2011-08-26T16:46:50+0000
id : 10150286459498721
message : Trivia Tuesday: What keyboard shortcut is also known as “the three-finger salute”?
likes : {#{id=100002695750862; name=Animalman Smooth}, #{id=100002727450944; name=Sébastien Popczyk}, #{id=100002706279284; name=Barbados Mayne}, #{id=1000001456612
54; name=Aman Goyal}...}
comments : {#{id=10150286459498721_18256946; message=ctrl-alt-delete; likes=2; from=; created_time=2011-08-23T14:06:08+0000}, #{id=10150286459498721_18256947; message=
- -; from=; created_time=2011-08-23T14:06:12+0000}, #{id=10150286459498721_18256951; message=control/alt/delete?; from=; created_time=2011-08-23T14:06:15+00
00}, #{id=10150286459498721_18256955; message=i dont knw; from=; created_time=2011-08-23T14:06:21+0000}...}
from : #{id=20528438720; name=Microsoft; category=Company}
updated_time : 2011-08-23T14:05:57+0000
...
Related
I'm using RestFB to get the data for FB comments, in particular the message_tags. It seems to work fine when the type of the message_tag is a "page", but I get an empty list when the type = "user".
Here is the FB commend id where this happens: 10156566664184478_10156576298439478
I'm using:
List msgtaglist = Comment.getMessageTags();
to get the list of MessageTag's.
But it returns an empty list for the comment above, although the FB Graph Explorer shows there is a message tag.
Any help is appreciated.
Thanks
Reinaldo
Prior to today, I used the following URL to get the Facebook share/like/comment count of a URL:
https://api.facebook.com/method/links.getStats?format=json&urls=http://stackoverflow.com/
Today, Facebook removed this feature. So now I'm using this:
https://graph.facebook.com/v2.7?emc=rss&fields=og_object{engagement},share&access_token=<ACCESS_TOKEN_GOES_HERE>&id=http://stackoverflow.com/
Which outputs:
{
"og_object": {
"engagement": {
"count": 45267,
"social_sentence": "45K people like this."
},
"id": "10150180465825637"
},
"share": {
"comment_count": 12,
"share_count": 45267
},
"id": "http://stackoverflow.com/"
}
The problem is, share_count is the total of likes + comments + shares (as far as I know).
Is there a way to get the number of likes, comments, and shares separately?
Looks like a bug in fb-api.
My solution:
receive the number of shares/comments as you describe in your question with
graph.facebook.com/?fields=og_object{id},share&id=https://stackoverflow.com/
save shares/comments count
save fb object-id of url
og_object->id
get likes count with (max limit is 1000, then you can use paging):
graph.facebook.com/OBJECT_ID/likes?access_token=ACCESS_TOKEN&pretty=1&limit=1000
UPD 2016-08-22
I found a solution that allows you to get the number of likes/reposts/comments in one step:
https://graph.facebook.com/?fields=og_object{likes.limit(0).summary(true)},share&ids=http://google.com,http://twitter.com
It is not currently possible.
Facebook is adding likes/shares/comments for URLs and returning them as shared_count.
Not possible to return correct number of individual likes/shares/comments, and that is not clear in the Graph API documentation. Not clear if it is a bug or a documentation error.
The old Rest API that provided this data was turned off on the 18th August.
There is a comment from a Facebook engineer explaining this in reply to a bug report, in the answer to this Stack Overflow question:
Getting Facebook Share, Like and Comment Counts for a Given URL with API Graph v2.6
You can also subscribe to this bug report at Facebook, but is a bit old with still no solution:
https://developers.facebook.com/bugs/748651458568287/
I have been using the following code to get Facebook shares for URLs, and show them on my website. It worked very well until a few days ago. Does FB changed anything in the Graph? Do you have any solutions to solve the problem.
$url='https://mywebsite.com/a/101';
$fb='https://graph.facebook.com/?ids='.$url;
$fbjson=file_get_contents($fb);
$fbobj = json_decode($fbjson);
$fbshares=$fbobj->{'shares'};
echo $fbshares;
Note, when I use the url address I see the url shares count, eg.
https://graph.facebook.com/?ids=https://mywebsite.com/a/101
Gives me the following result:
{
"https://mywebsite.com/a/101": {
"id": "https://mywebsite.com/a/101",
"shares": 44
}
}
A little changes I saw,
try this:
$url='https://sahafyonline.com/blog/101';
$fb='https://graph.facebook.com/?ids='.$url;
$fbjson=file_get_contents($fb);
$fbobj = json_decode($fbjson);
print_r($fbobj);
$fbshares=$fbobj->$url->{'shares'};
echo $fbshares;
I'm very confused... I try to setup a a fql fan page query, and in my search, I found that my user have several ID... So which should I use ?
Maybe more explaination is needed ^^
The first userId that I found is 4101606156331 (https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=me%3Ffields%3Did%2Cname&version=v2.0)
The second one is 1768286839 (https://graph.facebook.com/chapit.nicolas)
Which is the correct one ? And Why there are two IDs ? (maybe more...)
Someone can confirm me that which is the right ID (260226614127613 or 320233158126958) is the right one for the page CodeRougeAuto ? Because I like this page but when I try to know if I like the page with fql in Graph explorer tool (with a active token) I got this :
SELECT uid
FROM page_fan
WHERE uid=UID AND page_id=PAGEID
4101606156331 and 260226614127613 : empty response
4101606156331 and 320233158126958 : empty response
1768286839 and 260226614127613 : Error The global ID 1768286839 is not allowed. Please use the application specific ID instead
1768286839 and 320233158126958 : Error The global ID 1768286839 is not allowed. Please use the application specific ID instead
Thank you for your precious help !
What you see are the so-called global and app-scoped user_ids. If you're using v1.0 of the Graph API, the user_ids will be global. If you use v2.0 they will be app-scoped, as in your first example.
It's all in the docs: https://developers.facebook.com/docs/apps/upgrading#upgrading_v2_0_user_ids
I'm using django-facebook's Open Facebook API to try to defer a post with an image to a facebook page. The (relevant part of the) code is:
graph_api = OpenFacebook(integration.long_lived_page_token)
message = "something"
picture = "http://example.com/image.jpg"
d = datetime.datetime.strptime('07-25-2014 06:40 pm UTC', '%m-%d-%Y %I:%M %p %Z')
timestamp = timestamp = int(time.mktime(d.timetuple()))
try:
facebook_response = graph_api.set('/{0}/feed'.format(
facebook_page_id), message=message,
link=picture, picture=picture,
scheduled_publish_time=timestamp, published=0)
except:
...
This seems to work fine (I get the post id on facebook_response) but when the time comes to post this scheduled post nothing happens. When I check at the facebook page I see an error saying 'Sorry, something went wrong publishing this scheduled post' and offers to delete it or post it then. So, I can't seem to figure out what am I doing wrong.
I found a similar question but it does not offer a good answer.
Oh, I forgot to say when I remove timestamp and published=0 parameters (i.e. I post on that exact moment), the post gets created and published on the page's feed.