So I figured how to access a user's friends list using the graph API:
<?php
if($user_id) {
try {
$friends = $facebook->api("/me/friends/work_history");
}
catch(Exception $o){
d($o);
}
}
?>
If I get rid of work_history it will return a list of friends by echoing $friends. If I keep work_history there it just returns a blank data array. I've granted permissions via the test user to access friends work history but nothing returns.
How do I access a list of the test users friends work history?
Specify that you want the work field by accessing this url:
https://graph.facebook.com/me/friends?fields=id,name,work&access_token=...
By default, user_work_history is not accessible. If you want, you have to take a review by Facebook. It will be very tough, though.
https://developers.facebook.com/docs/apps/review
Related
I have a desktop application in which I need to make a user authentication with oAuth2.0.
I looked at the Facebook example but it doesn't really correspond to what I have to do or I don't understand it well.
In fact, I create an O2 instance:
O2* o2Auth;
o2Auth = new o2Auth(this);
o2Auth->setClientId(CLIENT_ID);
o2Auth->setClientSecret(CLIENT_SECRET);
o2Auth->setRequestUrl(REQUEST_URL);
o2Auth->setTokenUrl(TOKEN_URL);
But I don't understand how to authenticate the user with the user name and password. Which function do I have to use to do that?
In Facebook example, there is:
if (argList.contains(OPT_OAUTH_CODE)) {
// Start OAuth
fbdemo_.doOAuth(O2::GrantFlowAuthorizationCode);
} else if (argList.contains(OPT_VALIDATE_TOKEN)) {
fbdemo_.validateToken();
}
where argList is the parameters given to the application but they are not the user name and password.
In the tweeter example, there is :
oxTwitter_->setUsername(username);
oxTwitter_->setPassword(password);
but I didn't find the equivalent in O2.
I think I have to use things like GET and POST functions in the OSRequestor class, but how to link a OSRequestor instance to my O2 instance?
So what do I need to send user name and password to do the authentication with O2?
We are converting to Facebook's unity SDK and running into an issue downloading the profile images of friends. We are getting this error:
error getting user picture Failed downloading https://graph.facebook.com/#USERIDHER#/picture?type=square?access_token=#OURTOKENISHERE#
The app has permission for friends_photos. Is there another permission required for this?
I'm doing it using the code from the sample Friends Smash Application, while using the default permissions.
Get the list of the friends by using the Graph API and astore it in m_friendData dictionary:
FB.API("/me?fields=id,first_name,friends.limit(20).fields(first_name,id)", Facebook.HttpMethod.GET, GetFbFriendsCallback);
Retrieving the friend avatar:
FB.API(Util.GetPictureURL((string)m_friendData["id"], 96, 96), Facebook.HttpMethod.GET, this.FriendPictureCallback);
The callback which process the answer:
`public void FriendPictureCallback(FBResult result)
{
if (result.Error != null)
{
Debug.LogError(result.Error);
return;
}
friendAvatarImage.image = result.Texture;
}
`
Hope this helps.
This is apparently a known issue for the SDK and is being worked on since March 5th, see this reference:
https://developers.facebook.com/x/bugs/364606280347510/
I have an Instagram application written in Coldfusion 8 that basically pulls in media by tags and then allows people to Like / vote on the photos which is all done via the Instagram API. The Liking part is causing me no end of grief though, as I can get the Authentication and Access_Token without a drama, however the Access_Token doesn't appear to have permission to Like by default. There is an optional param for the Authenticate call "scope" which allows you to pass the permissions allowed for the Access_Token but i cannot work out how to pass this via ColdFusion CFHTTP as a POST.
Here is the preparation for the data to be sent over CFHTTP looping over all params as type="FormField". No matter how I try and present the scope options, either JSON format, string with spaces, string with "+" delimiters it seems to have no effect and the Like operation continues to fail due to permission errors.
<cfscript>
var LOCAL = {};
LOCAL['config'] = {};
LOCAL['returnStruct'] = {};
// prep packet required by the main call method
// the following values are required for EVERY call
LOCAL['config']['method'] = 'POST';
LOCAL['config']['format'] = ARGUMENTS['outputType'];
LOCAL['config']['url'] = VARIABLES.authURL;
// variables required by this method
LOCAL['config']['params'] = {};
LOCAL['config']['params']['client_secret'] = ARGUMENTS.client_secret;
LOCAL['config']['params']['grant_type'] = 'authorization_code';
LOCAL['config']['params']['redirect_uri'] = ARGUMENTS.redirect_uri;
LOCAL['config']['params']['code'] = ARGUMENTS.code;
LOCAL['config']['params']['scope'] = 'likes comments relationships';
</cfscript>
If anyone else is running into the same issues with "scope" not being correctly applied to the return Access_Token it turns out the problem was Instagram Documentation being vague about where this argument should be used. I had tried it every way possible as a POST operation as it suggested during the server-side Authentication, however it appears to only work if sent as GET params and after some playing around I decided to tack the "scope" param onto the 2nd stage of the authentication which is where the Code is requested and that worked! See below
https://api.instagram.com/oauth/authorize/?client_id=YOUR_CLIENT_ID&redirect_uri=YOUR_REDIRECT_URI&response_type=code&scope=likes+basic
This will present the user with an confirmation message from Instagram to allow the application to perform Likes on behalf of the user and everything else works like a charm after this.
I have an application which I developed about a year ago and I'm
fetching facebook accounts like this:
facebookClient = new DefaultFacebookClient(access_token);
Connection<CategorizedFacebookType> con = facebookClient.fetchConnection("me/accounts", CategorizedFacebookType.class);
fbAccounts = con.getData();
It worked fine until about a month ago, but now it returns the
fbAccounts list empty. Why is that?
I was hoping moving from restfb-1.6.2.jar to restfb-1.6.9.jar would
help but no luck, it comes up empty on both.
What am I missing?
EDIT, to provide the code for another error I have with this API. The following code used to work:
String id = page.getFbPageID(); // (a valid facebook page id)
FBInsightsDaily daily = new FBInsightsDaily(); // an object holding some insights values
try {
Parameter param = Parameter.with("asdf", "asdf"); // seems like the param is required
JsonObject allValues = facebookClient.executeMultiquery(createQueries(date, id), JsonObject.class, param);
daily.setPageActiveUsersDaily((Integer)(((JsonArray)allValues.opt("page_active_users_daily")).getJsonObject(0)).opt("value"));
...
This throws the following exception:
com.restfb.json.JsonException: JsonArray[0] not found.
at com.restfb.json.JsonArray.get(JsonArray.java:252)
at com.restfb.json.JsonArray.getJsonObject(JsonArray.java:341)
Again, this used to work fine but now throws this.
You need the manage_pages permission from the user to access their list of adminned pages - a year ago I'm not sure you did - check that you're obtaining that permission from your users
{edit}
Some of the insights metrics were also deprecated, the specific values you're checking may no longer exist - https://developers.facebook.com/docs/reference/fql/insights/ should have the details of what is available now
Try to check your queries manually in the Graph API Explorer to eliminate any issues in your code and hopefully get more detailed error messages that your SDK may be swallowing
I have the following code.
public void PostToWall(string message, string targetId)
{
dynamic parameters = new ExpandoObject();
parameters.message = message;
parameters.target_id = targetId;
dynamic result = _fbApp.Api("/me/feed", parameters, HttpMethod.Post);
}
Which works fine when the targetId is the id of the user authenticated.
However, when targetId is that of one of the authenticated users friends it doesn't work.
Anyone have any idea why?
I would suspect because you're trying to post to your feed, not the friend - /me/feed
The FB GraphAPI specifies that you POST to http://graph.facebook.com/PROFILE_ID/feed.
Sorry to tell you, but you can't actually do this.
Facebook has change the privacy settings, so that you can't access your friends wall using an app
Please find the relevant info here
https://developers.facebook.com/roadmap/completed-changes/
(look for the change of February 6th)