I'm using Parse Version 1.2.19 and I can't access a facebook user's name.
if ([PFFacebookUtils isLinkedWithUser:[PFUser currentUser]]) {
// Create Facebook Request for user's details
FBRequest *request = [FBRequest requestForMe];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
NSString *displayName = result[#"name"];
if (displayName) {
self.title =[NSString stringWithFormat:NSLocalizedString(#"Welcome %#!", nil), displayName];
}
}else{
NSLog(#"%#",[error description]);
}
}];
}
I get the following error:
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x29e24040 {com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:HTTPStatusCode=400}
These 2 posts claim the issue is fixed in the latest parse version:
https://www.parse.com/questions/error-when-trying-to-reauthorise-facebook-user
https://www.parse.com/questions/oauthexception-code-2500-an-active-access-token-must-be-used
It seems I needed this:
[PFFacebookUtils initializeFacebook];
Before calling the request. That line of code wasn't being called when the app just reloaded.
Related
My app is recieving a error when making a GET Request to the Facebook API for the endpoint me.
Here is my code:
-(void) updateUserInformation{
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc] initWithGraphPath:#"/me:" parameters:#{#"fields": #"id, name, email, user_birthday"}];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if(!error){
NSDictionary *userDictionary = (NSDictionary *)result;
NSMutableDictionary *userProfile = [[NSMutableDictionary alloc] initWithCapacity:8];
if (userDictionary[#"name"]) {
userProfile[#"name"] = userDictionary[#"name"];
}
if (userDictionary[#"first_name"]) {
userProfile[#"first_name"] = userDictionary[#"first_name"];
}
if (userDictionary[#"location"][#"name"]) {
userProfile[#"location"] = userDictionary[#"location"][#"name"];
}
if (userDictionary[#"gender"]) {
userProfile[#"gender"] = userDictionary[#"gender"];
}
if (userDictionary[#"birthday"]) {
userProfile[#"birthday"] = userDictionary[#"birthday"];
}
if (userDictionary[#"interested_in"]) {
userProfile[#"interested_in"] = userDictionary[#"interested_in"];
}
[[PFUser currentUser] setObject:userProfile forKey:#"profile"];
[[PFUser currentUser] saveInBackground];
}else {
NSLog(#"Error in Facebook Request %#", error);
}
}];
}
There error that I am getting is:
2015-10-11 14:30:59.306 MatchedUp[2358:139193] Error in Facebook Request Error Domain=com.facebook.sdk.core Code=8 "(null)" UserInfo={com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=803, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 803;
"fbtrace_id" = "CfGbwnx4/B9";
message = "(#803) Some of the aliases you requested do not exist: me:";
type = OAuthException;
};
};
code = 404;
}, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=404, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=(#803) Some of the aliases you requested do not exist: me:, com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0}
I am not very sure what this error means. It says "Some of the aliases you requested do not exist: me:" does that mean the result dictionary in the completionHandler does not contain some of the information for the endpoint me? Any help would be appreciated. Thank you!
Try changing your graph path #"/me:" to just #"me".
Good luck!
In My app I'm Trying to integrate the Facebook With Login By Using FaceBookSDK V4,Here i Successfully logged In and trying to Get the User's Email i'm Getting Error.In viewDidLoad i put theFollowing Code:
FBSDKLoginButton *loginButton = [[FBSDKLoginButton alloc] init];
loginButton.frame=CGRectMake(50,100,500,50);
loginButton.readPermissions=#[#"email"];
[self.view addSubview:loginButton];
[[[FBSDKGraphRequest alloc] initWithGraphPath:#"me" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error)
{
NSLog(#"fetched user:%# and Email : %#", result,result[#"email"]);
}
else{
NSLog(#"Error %#",error);
}
}];
Finally i'm Getting the Following Error:
Error Domain=com.facebook.sdk.core Code=8 "The operation couldn’t be completed. (com.facebook.sdk.core error 8.)" UserInfo=0x15d9b570 {com.facebook.sdk:FBSDKGraphRequestErrorGraphErrorCode=2500, com.facebook.sdk:FBSDKGraphRequestErrorParsedJSONResponseKey={
body = {
error = {
code = 2500;
message = "An active access token must be used to query information about the current user.";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:FBSDKGraphRequestErrorHTTPStatusCodeKey=400, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=An active access token must be used to query information about the current user., com.facebook.sdk:FBSDKGraphRequestErrorCategoryKey=0}
If you're using Parse, you need to switch out the ParseFacebookUtils with ParseFacebookUtilsV4 and update accordingly. Regular ParseFacebookUtils does not work with FB SDK V4, and you end up with very cryptic errors and random run-time failures (such as the elusive error code 8).
I am trying to retrieve list of FB friends which use the app. It was working fine until last month. I just realized that it is not working any longer. I am using the following block to achieve the results:
[FBRequestConnection startForMyFriendsWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
}
else
{
NSLog(#"%#",error)
}
}];
But quite contrary to previous results, Now I get the following error:
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x174278280 {com.facebook.sdk:HTTPStatusCode=400, com.facebook.sdk:ErrorSessionKey=<PFReceptionist: 0x174026dc0>, com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 100;
message = "(#100) Unknown fields: username.";
type = OAuthException;
};
};
code = 400;
}}
Has the facebook sdk changed lately? It might be so because I can't get the gender and date of birth too now, which I was able to retrieve before. What do you reckon is the issue? How can I retrieve the friends who are using my app, as it is quite crucial for my app?
I fixed it using this block instead.
FBRequest *friendsRequest = [FBRequest requestForGraphPath:#"/me/friends"];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,NSDictionary* result,NSError *error) {
if(error)
{
NSLog(#"%#", error);
}
else
{
NSLog(#"%#", result);
}
}];
I am trying (failing alot!) to use the Facebook iOS sdk. I want to publish a story about the user running without leaving the app. I am trying to use the Facebook built in object "course" and the built in action for a run.
I find the documentation very confusing, my code has become very tangled and I'm sure its the worst way possible of trying to implement this solution.
The error I'm getting with the following code is:
2014-04-01 23:10:13.238 Fitness_App[2313:60b] Encountered an error posting to Open Graph: Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x16ba5190 {com.facebook.sdk:HTTPStatusCode=500, com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 1611072;
message = "The action you're trying to publish is invalid because it does not specify any reference objects. At least one of the following properties must be specified: course.";
type = Exception;
};
};
code = 500;
}, com.facebook.sdk:ErrorSessionKey=}
I have been struggling with this and could not get a solution!
-(void) publishStory
{
// instantiate a Facebook Open Graph object
NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject openGraphObjectForPost];
// specify that this Open Graph object will be posted to Facebook
object.provisionedForPost = YES;
// for og:title
object[#"title"] = #"running title";
// for og:type, this corresponds to the Namespace you've set for your app and the object type name
object[#"type"] = #"fitness.course";
// for og:description
object[#"description"] = #"running description";
// Post custom object
[FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(!error) {
// get the object ID for the Open Graph object that is now stored in the Object API
NSString *objectId = [result objectForKey:#"id"];
NSLog([NSString stringWithFormat:#"object id: %#", objectId]);
// Further code to post the OG story goes here
// create an Open Graph action
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:objectId forKey:#"fitness.course"];
[FBRequestConnection startForPostWithGraphPath:#"/me/fitness.runs" graphObject:action completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(!error) {
NSLog([NSString stringWithFormat:#"OG story posted, story id: %#", [result objectForKey:#"id"]]);
} else {
// An error occurred, we need to handle the error
NSLog(#"Encountered an error posting to Open Graph: %#", error.description);
}
}];
} else {
// An error occurred
NSLog(#"Error posting the Open Graph object to the Object API: %#", error);
}
}];
}
Two places where things went wrong.
object[#"type"] = #"fitness.course";
The type should equal #"namespace:object".
[action setObject:objectId forKey:#"fitness.course"];
The key is your object name.
Check your code again and have fun ^-^
Try replacing your this sentence
"[action setObject:objectId forKey:#"fitness.course"];"
with this one
"[action setObject:objectId forKey:#"course"];"
i am trying to create an event but getting error . i am writing following code to create event using facebook sdk 3.1
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"My Test Event",#"name",
#"Bangalore",#"location",
#"1297641600",#"start_time",
#"1297468800",#"end_time", nil];
NSString * pRequest = [NSString stringWithFormat:#"me/events"];
[FBRequestConnection startWithGraphPath:pRequest parameters:params HTTPMethod:#"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error)
{
NSLog(#"Facebook Post Success..");
} else
{
NSLog(#"Facebook Post Failed..");
NSLog(#"ERROR : %#", error.localizedDescription);
}
}];
error :
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0xa180200 {com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 100;
message = "(#100) Invalid parameter";
type = OAuthException;
};
};
code = 400;
}, com.facebook.sdk:HTTPStatusCode=400}
can anybody help .....
thanks in advance
The error is a 400 error a bad request. This means there is something wrong with you're request. Also the error that Facebook returns suggest that you have an invalid parameter. So I suggest to double check you're parameters that you are sending and make sure you sending the correct amount of parameters in the right order and the right values.