Fetching one's old Facebook status messages - facebook-graph-api

I want to fetch one's old Facebook status. I have written the code for the same but it looks like it is not working for me. The steps that I have followed are as follows:
First I use the below API to seek the code from Facebook (by prompting user to log in to the Facebook page)
https://www.facebook.com/dialog/oauth?client_id=xxyy&redirect_uri=http://xxyy/home.aspx&scope=publish_stream,read_stream";
Then I seek the AccessToken by passing the code obtained in the above point to the below api as:
https://graph.facebook.com/oauth/access_token?client_id=xxy&redirect_uri=http://xxyy/home.aspx&client_secret=xxyy&code=zzz"
Now there is a problem. I am not able to understand which API I need to use to fetch the old status of the logged in user. I guess I have the access token which is the key to fetching the info. But I am not able to find the relevant API.

I would recommend that you use FQL.
//PHP example:
$fql_query_url = 'https://graph.facebook.com/'
. '/fql?q=fql?q=SELECT status_id, message FROM status WHERE uid=me()'
. '&' . $access_token;
$fql_query_result = file_get_contents($fql_query_url);

The graph API and "post" feed is what you need. I don't usually do this but I need my old statuses!

Following code works for me for fetching Facebook Conversation:
String s = facebook.request("me/inbox");
System.out.println("Message...."+s);

Related

How to get a valid access token to query search result from Facebook graph API

I want to collect all the Facebook link from Facebook search function. What I'm using here is the Facebook graph API tool.
If I want to query the data for a keyword, for example: "limited";
I will use the URL:
https://graph.facebook.com/v11.0/search?q=limited&access_token={my_access_token}
My image
However, I got the result as in the image. When I tried to create a workplace app and tried to get the access token of that app, I got the message as in the second image.
Error message when getting the access token of a workplace app
What I need now is an access token that has the permission to retrieve the data from the Facebook search. After that, I can use python to handle the rest.
Please help me out, thank you very much!

How to programmatically post like and comment an URL on facebook?

This is confusing. So just to clarify:
REQ #1: To fetch basic stats for a URL, you send GET request to:
http://graph.facebook.com/?ids=http://some.com
(alternatively, FQL can be used to fetch stats for a URL, but that doesn't return the OpenGraph Object)
REQ #2: To fetch comments for a URL, you do a GET:
http://graph.facebook.com/comments/?ids=http://some.com
REQ #3: To fetch likes for a URL, you GET:
http://graph.facebook.com/likes/?ids=http://some.com
But how do you comment on / like a URL programmatically?
I guess, likes can be created using Open Graph API, right?
https://graph.facebook.com/me/og.likes?object=1234
where 1234 is the OpenGraph Object ID of an article (as returned by REQ #1).
But this requires an approval process, the like action has to be approved by Facebook.
Is there a better way to do this? Can I use for example the Graph API for all these things?
My goal:
Currently I'm using the Facebook like button and comments plugin to create likes and comments. But these use the JS SDK, which is huge, and they generate a lot of external requests. I wanna get rid of them and just send an AJAX request to my server, which would then asynchronously talk to Facebook, and it would post the Like / Comment.
Is this possible?
Thanks in advance!
I read through the Facebook docs briefly and I don't believe you can do this other than the way you indicated with authenticating.
You should also take a look at this thread: 'Like' a page using Facebook Graph API
You would need to authorize every single user before he would be able to like something, and you would need to go through a review process on Facebook. And i am pretty sure you would not get the required permissions approved just because you want to get rid of the JavaScript SDK overhead, to be honest.
The Social Plugins are asynchronously, so the overhead for downloading the SDK is irrelevant as it happens in the background and it is non-blocking.
I have an idea, to do this. You can use long term access token, Once you login you receive short term token. After receiving short term token you need to request your long term access token. Save that token in DB or file.
Then you can use Graph Api, to make requests. This will eliminate the need for access requirement every time you request api.
Just use access token you saved before.
Refer this documentation from Facebook for further clarity.
https://developers.facebook.com/docs/facebook-login/access-tokens
Happy Coding!
Atul Jindal

Getting an Access Token Without User Login in Facebook Graph API?

I am working with facebook graph api rsvp_event. I am using javascript SDK. Everything works great when the user is logged in. But when the user is not logged in, it gives an error.
I need information about who is attending a public event. I now understand that I would need an access token to retrieve this information. So, my question is how do I get the access token if no user is logged in? Is it impossible or is there a workaround? Could it be done server side using app_id and client_secret?
I am developing a ColdFusion page, but I can use PHP if needed. I have support for both.
I have heard the term *offline_access_permission*. They have removed this feature. Could it be done when it was still available?
EDIT:
Could this be achieved by test user? Say, on server side I login via test user, get the event information (Just a "get" request to read who is attending an event) and then log off. On the client side I do the rest ( user login, rsvp to an event).
I don't know much about "test user" or its purpose. Can anyone confirm whether this can be achieved or not?
Thanks in advance.
Are you sure you actually need the user's access token? According to documentation here you may need:
- a generic access_token for public events (those whose privacy is set to OPEN)
- a user access_token for a user who can see the event for non-public events
- an app access_token (for non-public events, must be the app that created the event)
- a page access_token (for non-public events, must be the page that created the event)
You can get info on how to get those tokens here https://developers.facebook.com/docs/concepts/login/access-tokens-and-types/
A good idea could be to store the attending users (in the DB) when you have access to the event - when some user is logged in.
UPDATE for getting the data from FileContent.
I don't know what API response exactly you are referring to, but from my experience they are returning data:
- serialized using JSON - you need to use DeserializeJSON(), for example like this:
local.returnStruct = DeserializeJSON( local.requestResult.FileContent );
or
local.returnStruct = DeserializeJSON( local.requestResult.FileContent.toString() );
send as something similar to URI. I'm using a function to get that data:
function getStructFromQueryString( queryString ) {
var ret = StructNew();
var i = 0;
var key = '';
for(i=1; i LTE ListLen(arguments.queryString,'&'); i++) {
key = ListGetAt(arguments.queryString, i, '&');
ret[ListFirst(key,'=')] = URLDecode(ListLast(key,"="));
}
return ret;
}
Basically what you want is a refresh token that can get access tokens when the user is offline, unfortunately facebook does not provide them anymore as far as i know.
To learn more about oauth2 pleas play around with https://developers.google.com/oauthplayground/ its a very nice tool to understand the oauth2 process.

Getting "This method must be called with an app access_token" adding test users via graph api

I'm trying to create Facebook test accounts using the graph API. (I need to be able to log into them from my iphone app). Here's how I'm getting the app access token:
https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=MY-CLIENT-ID&client_secret=MY-CLIENT-SECRET
which seems to work fine. And here's how I'm trying to create a user:
https://graph.facebook.com/MY-APP-ID/accounts/test-users?installed=true&name=TestUser1&permissions=read_stream&method=post&access_token=MY-APP-ACCESS-TOKEN
The response I'm getting is:
This method must be called with an app access_token
I looked at this post Problem with access token while creating Facebook Test Users. Not really familiar with PHP, and just to make sure, I did try to "url encode" the app access token returned before using it... but no goodness.
I'm using Fiddler to test my posts.
Thanks!
Facebook doesn't support test users for Native Mobile App
see related bug on bugzilla
http://bugs.developers.facebook.net/show_bug.cgi?id=17779
hope this helps
Did you remove the 'access_token=' part from access token that's returned from the first request? If not, then you'll have an incorrect request on the second call, since the URL will have 'access_token=' twice.

How to post a message on wall of facebook using a graph api

How to post a message on the wall of facebook or add comment to the thread using a graph api.I want a url of that.
like for adding a message to wall
https://graph.facebook.com/profile_id/feed?access_token=generated token&message=hi
But it not working ,it not get added to my wall.
You need to add &method=post to your request URL. Also, you must have the `publish_stream extended permission for your application.
https://graph.facebook.com/user_id/feed?method=post&message=hi&access_token=generatedtoken.. will work
instead of profile id give the user id
Hope this will work