क्वेरी करने के लिए एक सक्रिय एक्सेस टोकन का उपयोग किया जाना चाहिए, मैं खाता फ्रेमवर्क के माध्यम से फेसबुक को एकीकृत कर रहा हूं, मैंने खोज की और इसे करने के कुछ तरीके प्राप्त किए। यह पहली बार काम कर रहा था लेकिन बाद में यह लॉग के नीचे दिखा रहा है और कोई जानकारी नहीं दे रहा है।फेसबुक ios6 में उपयोगकर्ता जानकारी प्राप्त करें:
प्रवेश करें:
Dictionary contains: {
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
}
कोड मैं
ACAccountStore *_accountStore=[[ACAccountStore alloc] init];;
ACAccountType *facebookAccountType = [_accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
// We will pass this dictionary in the next method. It should contain your Facebook App ID key,
// permissions and (optionally) the ACFacebookAudienceKey
NSArray * permissions = @[@"email"];
NSDictionary *options = @{ACFacebookAppIdKey :@"my app id",
ACFacebookPermissionsKey :permissions,
ACFacebookAudienceKey:ACFacebookAudienceFriends};
// Request access to the Facebook account.
// The user will see an alert view when you perform this method.
[_accountStore requestAccessToAccountsWithType:facebookAccountType
options:options
completion:^(BOOL granted, NSError *error) {
if (granted)
{
// At this point we can assume that we have access to the Facebook account
NSArray *accounts = [_accountStore accountsWithAccountType:facebookAccountType];
// Optionally save the account
[_accountStore saveAccount:[accounts lastObject] withCompletionHandler:nil];
//NSString *uid = [NSString stringWithFormat:@"%@", [[_accountStore valueForKey:@"properties"] valueForKey:@"uid"]] ;
NSURL *requestURL = [NSURL URLWithString:[@"https://graph.facebook.com" stringByAppendingPathComponent:@"me"]];
SLRequest *request = [SLRequest requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:requestURL
parameters:nil];
request.account = [accounts lastObject];
[request performRequestWithHandler:^(NSData *data,
NSHTTPURLResponse *response,
NSError *error) {
if(!error){
NSDictionary *list =[NSJSONSerialization JSONObjectWithData:data
options:kNilOptions error:&error];
NSLog(@"Dictionary contains: %@", list);
userName=[list objectForKey:@"name"];
NSLog(@"username %@",userName);
userEmailID=[list objectForKey:@"email"];
NSLog(@"userEmailID %@",userEmailID);
userBirthday=[list objectForKey:@"birthday"];
NSLog(@"userBirthday %@",userBirthday);
userLocation=[[list objectForKey:@"location"] objectForKey:@"name"];
NSLog(@"userLocation %@",userLocation);
}
else{
//handle error gracefully
}
}];
}
else
{
NSLog(@"Failed to grant access\n%@", error);
}
}];
किसी भी सुराग मित्र क्या गलत हो रहा है ... धन्यवाद करते थे।
"self.facebookAccount" क्या संदर्भित करता है? –
ACAccount * facebook खाता; – BhushanVU
@ बुहक्सन, महान उत्तर !!! लेकिन मैं उपयोगकर्ता की तस्वीर लाने में सक्षम क्यों नहीं हूं? – user1673099