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

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/

Related

Cocos2dx facebook invitable_friend graph api

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

Getting Not Authorized error from twitcurl timelineUserGet method

I'm currently playing with C++ on Linux and Twitter using twitcurl. I've built twitcurl, and it seems to work generally, I've been able to tweet from a slightly customised version of the twitterClient sample from their project. However, I've been struggling to read user's timelines.
Now, I know general authentication is working as I manage to tweet as the correct user first.
However, when I try to read user timelines using the below code:
/* Get user timeline */
replyMsg = "";
printf( "\nGetting user timeline\n" );
if( twitterObj.timelineUserGet( true, false, 5 ) )
{
twitterObj.getLastWebResponse( replyMsg );
printf( "\ntwitterClient:: twitCurl::timelineUserGet web response:\n%s\n", replyMsg.c_str() );
}
else
{
twitterObj.getLastCurlError( replyMsg );
printf( "\ntwitterClient:: twitCurl::timelineUserGet error:\n%s\n", replyMsg.c_str() );
}
I get the following error:
twitterClient:: twitCurl::timelineUserGet web response:
<?xml version="1.0" encoding="UTF-8"?><hash><request>/1/statuses/user_timeline.xml? count=5?trim_user=1</request><error>Not authorized</error></hash>
I'm unsure whether this is related to the invalid url twitcurl generates with multiple ? symbols which might conflict with authentication.
The full source code can be found at https://github.com/paulspencerwilliams/CPlusPlusSocialPlayground/blob/master/twitterClient.cpp .
The following post helped me to solve the same problem
What steps will reproduce the problem?
Sending certain characters to twitter API (Any character that has to be percent encoding, except the blank space?).
What is the expected output? What do you see instead?
I'd expect
twitter's server to accept my oauth signature but it hits me in the
face instead.
What version of the product are you using? On what operating system?
r88, this problem applies to both linux and wii (through devkitpro)
Please provide any additional information below.
The problem can be fixed by removing the urlencode() calls within buildOAuthRawDataKeyValPairs() in oauth.cpp.
That is according to how twitter says we have to do it. I don't know (did not check) if that's how the oauth spec says it should be done but it is clearly how it works with twitter.
Did you write oauthlib.cpp?

Blackberry facebook SDK login browser error

I recently switched from using the BlackBerry Facebook SDK jar to using the project's source code (checked out from the tag that the jar was built from).
Ever since this switch, I've experienced BrowserField problems:
On a device, the loading graphics persists until I back out.
On a simulator I see:
Error requesting content for
https://www.facebook.com/dialog/oauth?scope=user_about_me,user_activities,user_birthday,user_education_history,user_events,user_groups,user_hometown,user_interests,user_likes,user_location,user_notes,user_online_presence,user_photo_video_tags,user_photos,user_relationships,user_relationship_details,user_religion_politics,user_status,user_videos,user_website,user_work_history,email,read_friendlists,read_insights,read_mailbox,read_requests,read_stream,xmpp_login,ads_management,user_checkins,friends_about_me,friends_activities,friends_birthday,friends_education_history,friends_events,friends_groups,friends_hometown,friends_interests,friends_likes,friends_location,friends_notes,friends_online_presence,friends_photo_video_tags,friends_photos,friends_relationships,friends_relationship_details,friends_religion_politics,friends_status,friends_videos,friends_website,friends_work_history,manage_friendlists,friends_checkins,publish_stream,create_event,rsvp_event,offline_access,publish_checkins,manage_pages&redirect_uri=http://www.facebook.com/connect/login_success.html&display=wap&client_id=[APPLICATION_ID]&response_type=token
Error message null.
where APPLICATION_ID is my correct application ID.
The above URL opens fine in my PC browser, and I have debugged for a while through the Facebook sdk's source and found nothing.
It is possible that the application id might have changed recently without me knowing, and my next step is to revert back to using the .jar just for testing purposes.
Has anyone seen similar behavior with the BlackBerry SDK before?
I'm not sure if this is what happened in your case, but I've seen that error when the ProtocolController is set before the BrowserField is initialized. Like so:
private BrowserField bf;
...
BrowserFieldConfig bfc = new BrowserFieldConfig();
// bf not initialized yet but no compiler error
bfc.setProperty(BrowserFieldConfig.CONTROLLER, new ProtocolController(bf){
public void handleNavigationRequest(BrowserFieldRequest request) throws Exception {
super.handleNavigationRequest(request);
}
public InputConnection handleResourceRequest(BrowserFieldRequest request) throws Exception {
return super.handleResourceRequest(request);
}
});
bf = new BrowserField(bfc);
add(bf);
bf.requestContent("http://www.google.com");
...
Simply setting the ProtocolController after the BrowserField is initialized but before content is requested solves it.

How execute a FQL Insights query with Facebook Graph API

I try without success to execute a FQL query using Graph API to get the value of Insights counters.
Does anyone know how I can do this?
I use "Facebook C# SDK" version 5.4.1, C# 4.0.
If I use C# sample code provided in the documentation
var fb = new FacebookClient(m_accessToken);
dynamic result = fb.Query("SELECT name, uid FROM user WHERE uid= me()");
I receive a good response
{"name":"","uid":100002632407830}
With the same syntax, If I request "pages_fans" Insights counter and use library 5.4.1
var fb = new FacebookClient(m_accessToken);
dynamic result = fb.Query("SELECT metric, value FROM insights WHERE object_id=6176018219 AND metric='page_fans' AND end_time=end_time_date('2011-12-31') AND period=period('lifetime')");
I receive always an empty response
{[]}
With the same code but with library 5.2.1
I receive always a good response
{[{"metric":"page_fans","value":"125535"}]}
It is the same problem described here : Error with FQL query with library 5.4.1 but with another syntax.
Currently I use FQL Insights queries using REST API (with libary 5.2.1) but I want to migrate to FQL Insights queries using the Graph API (with library 5.4.1) because the REST API is deprecated.
Where is the bug:
In my syntax request?
In the "Facebook C# SDK" library?
On Facebook server?
Best regards.
I made a request with the Facebook Graph API Explorer
https://graph.facebook.com/fql?q=SELECT metric, value FROM insights
WHERE object_id=6176018219 AND metric='page_fans' AND
end_time=end_time_date('2011-12-31') AND period=period('lifetime')
I receive always an empty response.
{
"data": [
]
}
It is a Facebook's bug.
A bug was created about it on Facebook : http://developers.facebook.com/bugs/232510993491615?browse=search_4f08c675cce9d2265724293
I found another way to retrieving the info which works reliably
I found another way of retrieving insights which seems to be reliable.
documentation found here http://developers.facebook.com/docs/reference/api/insights/.
with more options to allow format and period changes - below example.
https://graph.facebook.com/2439131959/insights/application_active_users/[period]?format=json&since=[timestamp]&until=[timestamp]&access_token=[access_token]
period is day, month, week, lifetime.
timestamp has to be a valid PST midnight only.
access_token = could be.
1. nothing for the metrics that don't need permission.
2. app_id|secret_code or
3. your authentication token granted that you have access to the insight data of the application or pages (ie owner or insight users).
C# sdk example:
FacebookClient fbClient = new FacebookClient([appID], [secret]);
DateTime untilDate= (new DateTime([Now].Year, [Now].Month, [Now].Day));
DateTime sinceDate= (new DateTime([Now].Year, [Now].Month, [Now].Day)).AddDays(-1);
TimeSpan t = (untilDate- new DateTime(1970, 1, 1));
int timestampUntil = (int)t.TotalSeconds;
t = (sinceDate- new DateTime(1970, 1, 1));
int timeStampSince = (int)t.TotalSeconds;
var result = (IDictionary<string, object>)fbClient.Get([appID] + "/insights/" + [metricID] + "/" + [period] + "?format=json&since="+timeStampSince+"&until="+timestampUntil );
Console.WriteLine(result["data"]);
Make sure you have the correct permissions when you get your Access Token
<fb:login-button perms="read_insights"></fb:login-button>
This issue related to Facebook C# SDK.
Probably best thing you can do is file a bug on codeplex, and replace usage of end_time_date to "time in seconds" and period to "lifetime".

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)