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);
}
}];
Related
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'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.
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 using the newest facebook SDK 3.8 for iOS. I want to post a comment to a wall post and I am having troubles. The following method I am using works maybe once or twice and then gives me the error:
Error: The operation couldn’t be completed. (com.facebook.sdk error 5.)
I am not sure if it has to do with "overdoing" posting because I am only posting twice when this happens and on different posts each time. Like I said, it happens out of no where (Everytime before it is a success). So I believe it is my code. Can anyone tell me if I am doing this right?
Thank you!
-(BOOL) postComment: (NSString *) postID :(NSString *) userPostMessage;
{
__block BOOL value;
postID=[NSString stringWithFormat:#"/%#/comments?message=%#",postID,userPostMessage];
[FBSession activeSession];
[FBRequestConnection startWithGraphPath:postID parameters:0 HTTPMethod:#"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
BOOL temp;
if (error)
{
NSLog(#"Error: %#", [error localizedDescription]);
temp = TRUE;
}
else
{
NSLog(#"Result: %#", result);
valueReturned = (NSString*)result;
temp = FALSE;
}
value = temp;
}];
return value;
}
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.