Cocos2dx facebook invitable_friend graph api - c++

I am trying to get friend list from facebook on cocos2dx game. But when I try, only available to get 25 friends. But in Facebook Graph API Test Site on facebook developer site, I can get more with limit paramter like the picture as below.
How can I implement this on Cocos2dx? The current codes are like this.
void Facebook::getFBFriends()
{
if(fb_user_id.empty() == true) return;
g_vFBFriends.clear();
std::string path = "/me";
FacebookAgent::FBInfo params;
params.insert(std::make_pair("fields", "invitable_friends"));
FacebookAgent::getInstance()->api(path, FacebookAgent::HttpMethod::Get, params, CC_CALLBACK_2(Facebook::onGetFriendsDone, this));
}

"Paging" is the keyword. Without the limit parameter, you only get the first 25 entries - and a link to get the next 25 in the JSON result.
More information: https://developers.facebook.com/docs/graph-api/using-graph-api/#paging

Related

Retrieving profile pictures of Facebook friends using facebook-sdk-unity

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/

Facebook Unity3d SDK doesnot include FBUtil and GameStateManager classes

I am trying to integrate facebook sdk in my unity android game. I can not find FBUtil and GameStateManager in SDK downloaded from developer site.
I got the userId using FB.UserId. Also got the response
"sending to Unity OnInitComplete({"access_token":"CAAUCMHNGlZCcBAHJBQAs7AoJNevkZAFbkpSRk60TURemvv4Y6IOu9NXjGcFjFRZAx9RoxwKT4ZBZASs0NLiYTmi4rl7RyWYdtxxhlKkSjoIWiqqDSBdSDKk0OppB2ZB4U6IgtqQs9PM8uNCaNF5xgqWn2c9DDkp4dJc9p38XONKpdwRF7qDHtM","user_id":"100003735696788","opened":true})"
Just after that when I tried to get profile picture of the user, using the code given on developer.facebook.com,
void LoginCallback() {
FB.API (
"/me/picture",
Facebook.HttpMethod.GET,
APICallback
);
}
The response I get is 4 question marks.
????
where is the problem? Please help..
I used this link using WWW in Unity and it worked well.. This is exactly what I did
Once you have the user id, create a WWW object like this:
WWW url = new WWW("http://graph.facebook.com/INSERT_USER_ID_HERE/picture?type=large");
Then in the LateUpdate I put an IF condition checking if the picture was loaded or not with a bool called loaded to avoid reloading the picture more than once
if (url.isDone && !loaded)
{
loaded = true;
Texture2D textFb2 = new Texture2D(50, 50, TextureFormat.ARGB32, false); //TextureFormat must be DXT5
url.LoadImageIntoTexture(textFb2);
PLANE_OR_QUAD_OBJECT.renderer.material.mainTexture = textFb2;
}
NOTE: url is visible in the whole class as well as loaded
If you need further help with this, let me know!
Normally Facebook picture API should return data with Texture type NOT text
For example, If you use code like #jkgm777 answer,
WWW url = new WWW("http://graph.facebook.com/INSERT_USER_ID_HERE/picture");
You should get Texture type that can use to replace your texture object in scene.
But If you want to get image url, USE THIS
http://graph.facebook.com/INSERT_USER_ID_HERE/picture?redirect=false
You will get this JSON for response
data: {
url: "{#IMAGE_URL#}",
is_silhouette: false
}

Retrieve wall photo from status through graph API

How can I retrieve this photo through graph API?
It is not possible to get photos posted to the wall of an event like your sample.
I had a client last summer who started a contest that had people post photos to an event wall. They asked me to get them for display on their website. We had to manually download them to get them.
You can look at the feed for that event using
/412778502140672/event?fields=feed
But there are no attachments, and no connections. I don't believe it is possible to even get an event's stream using FQL.
If you are working on Android then this way can help you
Request r=Request.newMeRequest(session, new Request.GraphUserCallback() {
#Override
public void onCompleted(GraphUser user, Response response) {
// TODO Auto-generated method stub
JSONObject jso=null;
try{
//Parse json here
}
catch ( Exception e)
{
//Log.d(sTag,e.getMessage());
}
}
});
Bundle paramsPics=r.getParameters();
paramsPics.putString("fields",
"photos");
r.setParameters(paramsPics);
Response response=r.executeAndWait();
In the "me/home" API call, an item that has a photo will have a "picture" field with the source URL for a low resolution picture. To get to original high resolution picture, and dimensional variants of it, you have to do another API call using the "object_id" field in the same JSONObject as the "picture" field.
Doing the graph call for the "object_id" will then give you a "source" field with the original source image URL, as well as an array of different image sizes.
EDIT:
Set the graph path to "412778502140672_425592530859269" for the post.
Set the graph path to "482760011786004" for the photo.

Failing to fetch CategorizedFacebookType

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

Posting to a friends wall using the facebook API. C#

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)