I would like to allow my iPhone App users to view and select from their facebook profile photos, download the photo to use as a profile pic. I am currently using the Facebook SSO SDK and successfully logging in and accessing Graph information. Have tried to access photo information (after successful SSO login) using
[facebook requestWithGraphPath:#"me/albums"];
but I just get an empty data object in return. I've tried using the Facebook API explorer, which is very helpful, and it does give me data for /picture and /photos and /albums. For some reason I don't get the same data using requestWithGraphPath with me/albums, me/picture or me/photos. Just plain "me" works fine but doesn't give me any picture info. Can anybody tell me what I'm doing wrong?
Note: this is the API reference: Facebook Graph API
I did get picture profile to work like this:
[facebook requestWithGraphPath:#"me?fields=picture"];
Update: really I want all of the Profile Photos which is a photo album so I need to know how to access albums through iOS. The profile picture I have successfully obtained now.
I have added permissions "user_photos" and "friends_photos" for photo albums according to API:
NSArray *permissions = [[NSArray alloc] initWithObjects:
#"user_likes",
#"user_birthday",
#"email",
#"publish_stream",
#"publish_actions",
#"user_photos",
#"friends_photos",
nil];
[facebook authorize:permissions];
When I say I'm getting empty data, this is the JSON result (in request:didLoad:) that gets returned:
{
data = (
);
}
From my log file output:
- (void) request:(FBRequest *)request didLoad:(id)result{
NSLog(#"%#",result);
}
Final Note: What finally worked was to use another device, which updated my permissions and then everything started working! My best guess is that the emulator and my iPhone were not updating my facebook permissions so I was being denied access to photos and getting an empty data array.
This SO question was a big help also: How to get photos of a facebook album in iPhone SDK?
For the sake of future viewers, I'm putting the answer to my own question since I haven't received a complete answer from anyone else.
First, you must have the right permissions, either "user_photos" or "friends_photos". Then you have to make sure that your test device updates your permissions -- I think restarting the device is what ultimately did it for me.
Once you've done that, you can get the JSON list of albums, after logging in via SSO, using this call:
[facebook requestWithGraphPath:#"me/albums" andDelegate:self];
This will give JSON array (under key data) with all kinds of information about each album, including the ID. To get a list of photos for a particular album ID (say its '123456789') do the following:
NSString * albumId = #"123456789";
NSString * path = [NSString stringWithFormat:#"%#/photos", albumId];
[facebook requestWithGraphPath:path andDelegate:self];
Your response will of course come via the FBRequestDelegate method request:didLoad where you can process the JSON data.
Download the FBGraph Api documents folder then add it to in your folder. and read the instruction on facebook developer site http://developers.facebook.com/docs/reference/api/.
This is the sample code - sample code
In this you will get a user profile pic in UIAlertView. You can show it where you want.
Related
I want to get all wall updates of user's google plus account like facebook.
I have seen official link for it which is
Google Plus Documentation for iOS
& I have downloaded sample from there which is here Google Plus SDK Sample
it works well for getting user's information like email id,profile name,user's friend list with images & for posting on google plus.
but I am not getting user's post & updates.
all I want is user's wall updates & user's friends updates from google plus like facebook does.
but from above link i have found nothing for getting wall updates.
I have searched google for this also & get nothing regarding above problem.
any help for above problem appreciated.
Thanks in advance
From a backend server you can easily perform this API call to read a user's public activities. You can see the REST API here:
https://developers.google.com/apis-explorer/#p/plus/v1/plus.activities.list
Combine this with a people.list and you can query for a user's friend activities on Google+.
On iOS, you probably don't want to make these API calls directly from a user's device. If you can, you should offload the work to a backend server to avoid overworking the mobile client. That said, you can perform an API query similar to listing people in circles:
GTLQueryPlus *query =
[GTLQueryPlus queryForActivitiesListWithUserId:#"me" collection:#"public"];
[[[GPPSignIn sharedInstance] plusService] executeQuery:query
completionHandler:^(GTLServiceTicket *ticket,
GTLPlusActivityFeed *actFeed,
NSError *error) {
}
If you put a breakpoint in the application on the function, the activities feed will be something like as follows:
(lldb) po actFeed
{
nextPageToken:"CAIQ44qZ58DgtwIgFCgB"
etag:""DOKFJGXi7L9ogpHc3dzouWOBEEg/UMVQXfw8ynZaTz31tpuZo473TsQ""
title:"Google+ List of Activities for Collection PUBLIC"
updated:"2013-07-16T04:04:34.697Z"
kind:"plus#activityFeed" items:[20]
}
The items array contains the actual activities that a user has publicly written on Google+.
I am receiving the following graph response when checking users into Facebook using the Facebook Graph API. I am using the facebook-ios-sdk within my iPhone application to do this.
{"error":{"type":"OAuthException","message":"An unexpected error has occurred. Please retry your request later."}}
I have not made any changes to my code today and I know for a fact (database logs, etc) that their have been successful checkins yesterday.
I'm asking the SO community whether or not they have received similar errors and how they attempted to resolve them?
I have already tried the following:
Revoked access to my application via Facebook.
Reset my offline_access token by forcing Facebook to generate a new one.
Keep in mind my application successfully shares via peoples Facebook walls as well and this is working as expected without any problems.
I request the following permissions from my users:
#"offline_access", #"publish_stream", #"publish_checkins", #"email"
EDIT:
Okay, so this is quite strange and I'm thinking that it's an error on Facebook's end.
I use the following code to tag friends in the checkin:
if ([self.selectedFriends count] > 0) {
[variables setObject:[self.selectedFriends componentsJoinedByString:#","] forKey:#"tags"];
}
fb_graph_response = [fbGraph doGraphPost:#"me/checkins" withPostVars:variables clientId:accessToken];
self.selectedFriends is simply an NSMutableArray of Facebook profile ID's separated by commas, which is what the graph API says to use and remember this has been working fine for months.
http://developers.facebook.com/docs/reference/api/checkin/
If I remove the [variables setObject:[self.selectedFriends componentsJoinedByString:#","] forKey:#"tags"]; then the checkin works just fine for me.
It fails every time I tag one or more friends. Is anyone else receiving the same error when tagging friends in a checkin?
UPDATE 1:
Looks like other people are receiving the same problem relating to Groups:
http://forum.developers.facebook.net/viewtopic.php?pid=349396
I wonder if there's a bug at the moment relating to Checkins.
I've posted a bug:
http://bugs.developers.facebook.net/show_bug.cgi?id=18134
UPDATE 2:
Facebook were able to reproduce the bug and they're now looking into it.
i m using checkins in one of my applications , Regarding your issue ,
Yes , you are right , i had this OAUTH Exception only when sometimes you made checkins continuously with tagging friends,
Also allow permissions like #"user_checkins", #"friends_checkins", in your application
please check this link :
http://tylerwhitedesign.com/how-to-check-in-using-the-facebook-ios-sdk-and-graph-api
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[dictionary objectForKey:#"place"], #"place", //The PlaceID
coordinates, #"coordinates", // The latitude and longitude in string format (JSON)
message, #"message", // The status message
tags, #"tags", // The user's friends who are being checked in
nil];
[_facebook requestWithGraphPath:#"me/checkins" andParams:params andHttpMethod:#"POST" andDelegate: postCheckinRequestResult];
Hope this helps!
I am developing a iPhone application in which I want to simply 'Like' my own Facebook AppID.
For Facebook integration I am using FBConnect and Graph API (https://github.com/facebook/facebook-ios-sdk/blob/master/README.mdown).
After researching, I found that I was supposed to use the following method, which I attempted to implement in the "DemoAppViewController.m" of the sample code when the 'publishStream' button was selected:
NSMutableDictionary *params = [NSMutableDictionary dictionary]; //Use an empty dictionary
[_facebook requestWithGraphPath:#"https://graph.facebook.com/163221793740496/likes"
andParams:(NSMutableDictionary *)params
andHttpMethod:#"POST"
andDelegate:(id <FBRequestDelegate>)self];
However, my FBRequest.m 'responseString' indicates: {"error":{"type":"GraphMethodException","message":"Unsupported post request."}}
What am I doing wrong and how can I make this work?
From what I understand, all I need to do is attach my accessToken to https://graph.facebook.com/163221793740496/likes. What exactly does that mean, and how is it accomplished?
Thanks in advance!
P.S. - In case there was any confusion, my post was in reference to having a user sign into Facebook with their account login via a fb like button in the application. After the user allowed the appropriate permissions, my app would 'like' the AppID with the user's account.
You can't programmatically like a page on Facebook. It would be enthusiastically abused.
I'm losing my mind over trying to get Facebook SDK for iPhone to upload UIImage.
Here's what I'm doing:
1) Creating facebook property:
facebook = [[Facebook alloc] initWithAppId:#"111111111"];
2) Calling authorize:
[facebook authorize:[NSArray arrayWithObjects:#"publish_stream", nil] delegate:self];
3) Setting params:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:image, #"picture", nil];
4) Calling post:
[facebook requestWithMethodName:#"photos.upload" andParams:params andHttpMethod:#"POST" andDelegate:self];
When loging in I get the authorize dialog. When trying to upload I receive error 101, Invalid API Key. I've copied the key from FB, I've included it as shown above and I've also included it in .plist (fbAPI_KEY). What the hell am I still missing here? When asked to authorize it did show the name of the app just fine so the key must be correct. I can also post feeds and they appear on users wall, but images just won't upload.
That's a bit weird, I've got the exact same four lines of code which work fine for me. (Although, your app id is a bit shorter than it should be, mine is roughly twice that size).
One thing you may be forgetting about: when are you using each line? You should wait till each of the previous tasks is completed by using the facebook delegates, eg:
- (void)fbDidLogin; //part of the <FBSessionDelegate> protocol
Use these methods to control when the next part of the uploading process should occur, and check for errors along the way. You may be trying to send the photo before the login process has actually finished - use the delegate methods to prevent this.
I think you have to use graph API for uploading images
Check Out:
Ref URL: http://www.raywenderlich.com/1626/how-to-post-to-a-users-wall-upload-photos-and-add-a-like-button-from-your-iphone-app
Hope this helps....
I want to publish information to user's wall from iphone application. I am using the Facebook SDK for iphone. I found in the documentation that I should use FBStreamDialog but this loads a form to the user and s/he write the story to be published, I don't want this behavior. I want to publish user actions at my application and user just needs to click share button, then the application should fill a template story and publish.
I found this use case was available before with FBFeedDialog but this is not supported via the API now.
Any suggestions, what I should do?
//Modified
here's an example for David's solution:
NSString *att = #"{\"name\":\"i\'m bursting with joy\",\"caption\": \"User rated the lolcat 5 stars\", \"description\": \"a funny looking cat\"}";
NSDictionary *attachment = [NSDictionary dictionaryWithObject:att forKey:#"attachment"];
[[FBRequest requestWithDelegate:self] call:#"facebook.stream.publish" params:attachment];
#"stream.publish"
I use this code occur error "The user hasn't authorized the application to perform this action"