I am working on a ios app.
I need to share a video link to facebook.Video will save on my server.
I am using below code:-
params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
AppName, #"title",
AppName, #"name",
[NSString stringWithFormat:#"%#",text], #"caption",
composeViewController1.text, #"description",
Path, #"link",
[NSString stringWithFormat:#"%#%#app_icon-DEMO.png",ServerPath,URLImageFolder], #"picture",
nil];
[FBRequestConnection startWithGraphPath:#"/me/feed"
parameters:params
HTTPMethod:#"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if (!error) {
// Link posted successfully to Facebook
NSLog(#"result: %#", result);
} else {
// An error occurred, we need to handle the error
// See: https://developers.facebook.com/docs/ios/errors
NSLog(#"%#", error.description);
}
}];
But i am getting below error from this
Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0xc52be90 {com.facebook.sdk:HTTPStatusCode=500, com.facebook.sdk:ParsedJSONResponseKey={
body = {
error = {
code = 1500;
"error_subcode" = 1609005;
message = "This link could not be posted.";
type = FacebookApiException;
};
};
code = 500;
But if i try to share static link say "www.google.com" it is working.
My app's flow is :-
User will check mark on facebook button and the feed will share on facebook and my app at the same time.
Thanks for help.
I don't know exactly whats going wrong here, but as far I know Facebook return com.facebook.sdk code=5 the operation couldn't be completed. (com.facebook.sdk error 5.) this error in few cases, like
Session is is not open.
Facebook has detected that you're spamming the system.
Facebook has a defined limit using the SDK.
You don't have permission to do so or wrong publish permission.
The link you have provided is not working. When I tried to open the link it's say
Facebook need to parse your url. May be that's why fb not give you to post the url.
Related
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 submit what I think is a pretty basic open graph post on facebook in iOS7. I am using the latest version of everything, including facebook's SDK version 3.10.
My app brings up the share dialog preloaded with the parameters from my FBGraphObject. I even had an image URL in there earlier that shows in the preview, just took it out trying to troubleshoot. I type a few words in the "Say something about this..." part of the share dialog and tap "Post." This is the error I get:
Error Domain=com.facebook.Facebook.platform Code=102 "The operation couldn’t be completed. (com.facebook.Facebook.platform error 102.)" UserInfo=0x19192ba0 {error_message=An error occurred during publishing., app_id=299416296871047, error_code=102}
I can't seem to find another question with this same error. Here is my code:
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
NSMutableDictionary<FBGraphObject> *object =
[FBGraphObject openGraphObjectForPostWithType:#"og.item"
title:#"Test Post"
image:nil
url:#"https://mywebsiteurl.com"
description:#"A test post"];
[action setObject:object forKey:#"something"];
[FBDialogs presentShareDialogWithOpenGraphAction:action
actionType:#"og.publish"
previewPropertyName:#"something"
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(#"Error: %#", error.description);
NSLog(#"Results: %#", results);
} else {
NSLog(#"Success.");
}//end if
}];
Any ideas?
I had the same problem. It turned out to be permission issue. Facebook user that that I used to post OG story wasn't administrator or the developer in the Facebook app roles and permissions.
In order to use it with any user your app has to be reviewed by Facebook.
I had the exact same problem. What's the size of the OG object in the URL?
Mine was rather large and the Facebook app was not waiting long enough to complete the post.
At the moment i'm publishing successfully via FBRequestConnection startForPostWithGraphPath
// create object
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:url forKey:#"something"];
[action setObject:#"true" forKey: #"fb:explicitly_shared"];
[FBRequestConnection startForPostWithGraphPath:#"me/og.item"
graphObject:action
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
}];
Make sure the 'Explicitly Shared' option for this action type is enables in the App Dashboard.
I am working on iOS App and it has a simple facebook sharing functionality, basically it allows you to share a link to this app by posting in feed.
I am using facebook SDK 3.2.1 this way:
NSMutableDictionary *params =
[NSMutableDictionary dictionaryWithObjectsAndKeys:
#"Test tweet", #"name",
#"Test", #"description",
#"http://myapplink.com",
#"link",
#"http://myapppicture.com/picture.jpg",
#"picture",
nil];
[FBWebDialogs presentFeedDialogModallyWithSession:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) {
if (error) {
NSLog(#"Error publishing story.");
} else {
if (result == FBWebDialogResultDialogNotCompleted) {
NSLog(#"User canceled story publishing.");
} else {
NSLog(#"No error!");
}
}
}];
The problem is: when this code runs, it brings up facebook login dialog and after I log in, I see this error on screen: "An error occured. Please try again later".
There's nothing logged in console, but if i close this dialogs, it only logs "User canceled story publishing."
Application settings are very basic - I've setup everything just like facebook asked to do:
http://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/
My question is: has anybody came across the same problem? what can be possible solution?
Thanks!
Now this was fairly simple and I feel kinda stupid :)
But anyway, I hope this will help anybody who will be in the same problem.
Generally, I solved the problem by adding one more key-value pair to my "params" dictionary - value #"my_facebook_app_id" for key #"app_id".
So the correct dictionary looks like:
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
#"11111111", #"app_id",
#"Test tweet", #"name",
#"Test", #"description",
#"http://sometestsite", #"link",
#"http://site.com/testimage.jpg", #"picture",
nil];
Facebook SDK says that app_id key is "Required, but automatically specified by most SDKs" - and even though I provided my app_id via MyApp-Info.plist file, it seems like it was not automatically specified (or I did something wrong).
So if you have the same problem, try adding this #"app_id" key - this should help.
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.
I'm trying to post Photo, URL, message and name to Facebook from my iOS application to user's wall. I'm using latest Facebook framework 3.1
I'm using following code:
NSDictionary* dict = #{
#"link" : #"https://www.yahoo.com",
#"picture" : UIImagePNGRepresentation([UIImage imageNamed:#"Default.png"]),
#"message":#"Your message here",
#"name" : prodName,
#"caption" : [NSString stringWithFormat:#"Try the app: %#", prodName],
#"description" : #"Integrating Facebook in ios"
};
[FBRequestConnection startWithGraphPath:#"me/photos" parameters:dict HTTPMethod:#"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSString *alertText;
if (error)
{
NSLog(#"%#",[NSString stringWithFormat: #"error: domain = %#, code = %d", error.domain, error.code]);
alertText = #"Failed to post to Facebook, try again";
} else
{
alertText = #"Posted successfully to Facebook";
}
[[[UIAlertView alloc] initWithTitle:#"Facebook Result" message:alertText delegate:nil cancelButtonTitle:#"OK!" otherButtonTitles:nil] show];
}];
I'm able to post successfully. But I'm seeing in Facebook that, its posting only photo and message and not other details. If I'm using #"me/feed", I'm not even able to post successfully. Facebook is giving error code=5.
How can I post all the details?
"me/feed" requires a url for the "picture" parameter. Please take a look at this link: a previous post on posting a photo on user's wall
Looks like you have to decide whether to use "me/photos" or "me/feed". This link will give you more information and may be a possible way around it.