FBConnect iphone : I coud'nt get Photos albums for some account ? - iphone

Maybe someone can't help me.
I use the last FBConnect (http://github.com/facebook/facebook-ios-sdk/) for Facebook connexion.
And I retreive the list of photos albums for the user.
NSMutableDictionary* params = [NSMutableDictionary NictionaryWithObjectsAndKeys:_facebook.accessToken,#"access_token",nil];
[_facebook requestWithGraphPath:#"me/albums" andParams:params andDelegate:self];
I'm testing with 4 differents account with all the same rules for privacy (Account/Privacy settings). And for some of them the albums list is empty ? And if i test via a webbrowser on a desktop computer (https://graph.facebook.com/me/albums) for account who doesn't work on iphone, the list is not empty ?
On iphone, i use graph api or FQL with same results ("SELECT aid FROM album WHERE owner = me()")
Maybe i miss some think about configuration off the facebookapp ?
Thanks for answer.

I resolve the solution with good settings for facebook authentifications
http://developers.facebook.com/docs/authentication/permissions

THIS WILL PUT ALL THE IMAGES OF THE ALBUM IN SOURCE ARRAY!
NSURL *url1 = [NSURL URLWithString:[NSString stringWithFormat:#"https://graph.facebook.com/%#/photos&access_token=AAACeFkezepQBANpoFq9I3Hts0JdE6Xis3UpZBqNxpgw62zWSlhSYyYcluGaaxH3IlKIh9w8OYrXYF9MsAxhk6ta1ANZClCaznpdSaERgZDZD",A_ID]];
URLWithString:#"https://graph.facebook.com/114750591966408/photos&access_token=//AAACeFkezepQBANpoFq9I3Hts0JdE6Xis3UyYcluGaaxH3IlKIh9w8OYrXYF9MsAxhk6ta1ANZClCaznpdSaERgZDZD"];
NSData *data1 = [NSData dataWithContentsOfURL:url1];
NSString *str1=[[NSString alloc] initWithData:data1 encoding:NSASCIIStringEncoding];
// NSString *str1=[[NSString alloc]ini]
NSDictionary *userData1 = [str1 JSONValue];
NSArray *arrOfimages=[userData1 objectForKey:#"data"];
NSMutableArray *sourceUrls = [[NSMutableArray alloc] initWithCapacity:0];
for(NSDictionary *subDictionary in arrOfimages)
{
[sourceUrls addObject:[subDictionary objectForKey:#"picture"]];
}

publish_actions and user_photos permissions is required.
And then please try the following code :
[FBRequestConnection startWithGraphPath:#"me/albums"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Success! Include your code to handle the results here
NSLog(#"user events: %#", result);
NSArray *feed =[result objectForKey:#"data"];
for (NSDictionary *dict in feed) {
NSLog(#"first %#",dict);
}
} else {
// An error occurred, we need to handle the error
// Check out our error handling guide: https://developers.facebook.com/docs/ios/errors/
NSLog(#"error %#", error.description);
}
}];

Related

Not able to fetch the gmail address book in iPhone

From last few days i am stuck as i am not able to access my gmail address book in my iPhone app.I searched a lot but didn't get any success.
Here is the link that i refereed
I checked this link also to access gmail contacts
In the above link it is given that you can access the contacts using this url
https://www.google.com/m8/feeds/contacts/userEmail/full
I am able to login using GData framework but didn't find anything to fetch gmail contacts.
I have a access token after successful login and i am calling this method after logging in successfully.
- (void)doAnAuthenticatedAPIFetch {
NSString *urlStr = #"https://www.google.com/m8/feeds/contacts/myEmailId#gmail.com/full";
NSURL *url = [NSURL URLWithString:urlStr];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[self.authToken authorizeRequest:request
completionHandler:^(NSError *error) {
NSString *output = nil;
if (error) {
output = [error description];
} else {
NSURLResponse *response = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&response
error:&error];
if (data) {
// API fetch succeeded :Here I am getti
output = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];
} else {
// fetch failed
output = [error description];
}
}
}];
}
Please guide me.
Use this URL to get gmail account address book fetching.
http://code.google.com/p/gdata-objectivec-client/wiki/GDataObjCIntroduction
And take instruction from here how to use google api.
http://johntwang.com/blog/2009/06/08/how-to-use-google-apis-with-iphone-sdk/
hope this would be work for you.

Not receiving Facebook picture via Graph API

I can't seem to properly retrieve a user's profile picture using the current iOS graph method.
My call: self.pictureRequest = [facebook requestWithGraphPath:#"me/picture" andDelegate:self];
What I do with the result:
-(void)request:(FBRequest *)request didLoad:(id)result{
if(request == self.pictureRequest){
UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)];
image.image = [UIImage imageWithData:result];
[self.view addSubview:image];
NSLog("result is %#", result);
}
So I'm just trying to get the profile picture right now. Result shows up as null in the console. I guess this means I'm not actually getting a result? (I tried if(result) NSLog(#"got a result") but it doesn't return, so I'm guessing a result isn't being sent back by fb?)
Any ideas? I also looked up a similar problem here but not sure what they do differently:
Problem getting Facebook pictures via iOS
well I can retrieve the user pic and other info like this .. try it
- (void)fetchUserDetails {
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"SELECT uid, name, pic, email FROM user WHERE uid=me()", #"query",nil];
[fb requestWithMethodName:#"fql.query"
andParams:params
andHttpMethod:#"POST"
andDelegate:self];
}//Call this function after the facebook didlogin
and in request didLoad:
- (void)request:(FBRequest *)request didLoad:(id)result
{
if([request.url rangeOfString:#"fql.query"].location !=NSNotFound)
{
if ([result isKindOfClass:[NSArray class]] && [result count]>0) {
result = [result objectAtIndex:0];
}
if ([result objectForKey:#"name"]) {
self.fbUserName = [result objectForKey:#"name"];
// Get the profile image
UIImage *fbimage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[result objectForKey:#"pic"]]]];
}
If you want to get the picture URL using requestWithGraph path (instead of requestWithMethodName like #Malek_Jundi provides) then see my answer here:
iOS Facebook Graph API Profile picture link
You can also get fb profile picture url by,
NSString *userFbId;
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"https://graph.facebook.com/%#/picture", userFbId]];
NSData *imageData = [[NSData alloc] initWithContentsOfURL:url];
self.userProfileImage.image = [UIImage imageWithData:imageData];

How to get user account information from Twitter using objective-c?

i have used oauth mechanism to let the user login via twitter in my app, on successful login it returns me the access taken, username and oauth_token_secret, i want to get the user account information from twitter like his location, date of birth, and other profile information. I have searched the Rest Api given on the twitter's official site but haven't found any such link.... so how to get the user 's account information? kindly help me.
what about this call
https://api.twitter.com/1/users/show.json?screen_name=TwitterAPI&include_entities=true
Twitter-Kit Version 3.4.0 Here is function
-(void)userVerify:(NSString *)userID{
NSString *statusesShowEndpoint = #"https://api.twitter.com/1.1/users/show.json";
NSDictionary *params = #{#"id": userID};
NSError *clientError;
// Objective-C
TWTRAPIClient *client = [[TWTRAPIClient alloc] init];
NSURLRequest *request = [client URLRequestWithMethod:#"GET" URLString:statusesShowEndpoint parameters:params error:&clientError];
if (request) {
[client
sendTwitterRequest:request
completion:^(NSURLResponse *response,
NSData *data,
NSError *connectionError) {
if (data) {
// handle the response data e.g.
NSError *jsonError;
NSDictionary *json = [NSJSONSerialization
JSONObjectWithData:data
options:0
error:&jsonError];
NSLog(#"%#",[json description]);
self.txtViewDetails.text = [json description];
}
else {
NSLog(#"Error code: %ld | Error description: %#", (long)[connectionError code], [connectionError localizedDescription]);
self.txtViewDetails.text = [NSString stringWithFormat:#"Error code: %ld | Error description: %#", (long)[connectionError code], [connectionError localizedDescription]];
}
}];
}
else {
NSLog(#"Error: %#", clientError);
}
}

Facebook video Upload error

Facebook video upload error: i'm using the combination of the old
and the new API/SDK from the link https://github.com/zoul/facebook-ios-sdk/commit/efb4b44fad333f8daa70a517bb5328b9352320df
and i m getting session id properly in the video Upload class
- (void) startUploadWithURL: (NSURL*) movieURL params: (NSDictionary*) userParams delegate: (id ) delegate
{
apiKey = #"5c009deec3b253bef6fe6cdd97e86b3f";
appSecret = #"218421681dfb46043bed3dd25a03bbce";
if ([self sessionID] == nil) {
NSLog(#"Unable to retrieve session key from the access token.");
return;
}
printf(" \n\n session id == %s",[[self sessionID] UTF8String]);
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithDictionary:userParams];
[params setObject:#"1.0" forKey:#"v"];
[params setObject:#"facebook.video.upload" forKey:#"method"];
[params setObject:[self sessionID] forKey:#"session_key"];
[params setObject:apiKey forKey:#"api_key"];
[params setObject:[self signatureForParams:params] forKey:#"sig"];
[params setObject:[NSData dataWithContentsOfURL:movieURL] forKey:[movieURL lastPathComponent]];
[[FBRequest getRequestWithParams:params httpMethod:#"POST" delegate:delegate requestURL:kAPIURL] connect];
}
its returning the wrong result and not uploading video to the Facebook
Without using graph api you can upload videos to facebook.login facebook and go to this link. there you will get a id like xyz#m.facebook.com .just mail your videos to this mail id.you can use a MFmailcompossor to compose mail from your app.
Hope this help

Parse youtube playlist on iphone sdk/ iOS

Since Days i'm trying to parse a YOUTUBE-XML-Feed by using GDATA-API for iOS.
http://code.google.com/intl/de-DE/apis/youtube/2.0/developers_guide_protocol_channel_search.html
NSDictionary *namespaces = [NSDictionary dictionaryWithObjectsAndKeys:
#"http://www.w3.org/2005/Atom", #"",
#"http://schemas.google.com/g/2005", #"gd",
#"http://a9.com/-/spec/opensearch/1.1/",#"opensearch",
#"http://gdata.youtube.com/schemas/2007",#"yt",
#"W/"DkYGRH48fCp7ImA9Wx5WFEw."",#"gd:etag",
nil];
NSError *error = [[NSError alloc] init];
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:receivedData options:0 error:nil];
NSArray *elements = [doc nodesForXPath:#"//entry" namespaces:namespaces error:&error];
I don't get any results. Does anyone got an solution to this? Thanks in advance!
this is how I use this API
NSArray *entries = [doc.rootElement elementsForName:#"entry"];
for (GDataXMLElement *e in entries) {
// do something..
}
There is documentation on the GData Objective-C API, and a sample application for using the YouTube GData API is here.
I encountered a similar problem, it doesn't seem to deal well with a prefixless namespace.
Try changing:
#"http://www.w3.org/2005/Atom", #"",
to
#"http://www.w3.org/2005/Atom", #"atom",
and your xpath:
#"//entry"
to
#"//atom:entry"