I'm try to publish a local photo in a Facebook open graph story, but the image is not appears.
This code is the same of the documentation page of Facebook developers. facebook_developers open graph ios
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = [UIImage imageNamed:#"coffee-and-sunrise.jpg"];
// Optionally set user generated to YES only if this image was created by the user
// You must get approval for this capability in your app's Open Graph configuration
// photo.userGenerated = YES;
// Create an object
NSDictionary *properties = #{
#"og:type": #"books.book",
#"og:title": #"A Game of Thrones",
#"og:description": #"In the frozen wastes to the north of Winterfell, sinister and supernatural forces are mustering.",
#"books:isbn": #"0-553-57340-3",
};
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
// Create an action
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = #"books.reads";
[action setObject:object forKey:#"books:book"];
// Add the photo to the action. Actions
// can take an array of images.
[action setArray:#[photo] forKey:#"image"];
// Create the content
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = #"books:book";
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:nil];
Facebook is aware this is broken on iOS and has marked it as "won't fix". Incredibly agitating, please do voice your concern on the bug report they've acknowledged here.
Related
I am using Facebook SDK 4.13 for iOS.
I'm successfully share custom OpenGraph story through [FBSDKShareAPI share]. The problem is - no dialog.
When I'm trying to share the same context through FBSDKShareDialog - dialog appears empty and shared post neither.
Is there a possibilities to share OpenGraph stories through dialog?
I've managed "tune" settings for my OGOStory(OpenGraphObjectStory), so it'll show correctly in fine dialog.
It's a bit confusing that in my app I have models named story and OGOS but, i hope, youl'll manage to understand.
- (void)performShareFacebookWithStory:(STLStory *)story andText:(NSString *)text
{
NSURL *imageURL = [NSURL URLWithString:[story largeImageURL]];
FBSDKSharePhoto *photo = [FBSDKSharePhoto photoWithImageURL:imageURL userGenerated:NO];
NSDictionary *properties = #{
#"og:type": #"stories_california:story", //OpenGraphObjectStory,
#"og:title": [story title],
#"og:description": [story aboutText],
#"og:url": [self storyUrlForStory:story], // it's NSString
#"og:image": #[photo],
};
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = #"stories_california:story_listen";
[action setObject:object forKey:#"story"];
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = #"story"; //OpenGraphPreviewPropertyName
[FBSDKShareDialog showFromViewController:_parentVC
withContent:content
delegate:self];
}
I'm trying to share a photo to Facebook using the Open Graph API. I was unsure of how to share a photo so I'm starting off with code to just post a like. So far I have the following code:
// Create an object
NSDictionary *properties = #{
#"og:type": #"myObject",
#"og:title": #"title",
#"og:description": #"description",
};
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
// Create an action
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = #"og.likes";
[action setObject:object forKey:#"myObject"];
// Create the content
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = #"myObject";
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:nil];
I created a custom graph object on Facebook "myObject" and am trying to share or like this publicly on Facebook. I would love any help on this, when this code runs nothing shows up. Ideally I would like to add a photo to this object and be able to share it with a callback link to either my site (and eventually the app)!
try to use shareSDK~ it's nice
link: http://www.mob.com/en
You should go to open graph on facebook app and get code sample facebook auto generate:
Dashboard
Code autogenerate
I am trying to post story via my app using Graph API of facebook SDK.
I have configured actions and object and story on its App console, and have implemented following code to achieve the same.
NSURL *imageURL = [NSURL URLWithString:#"https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png"];
FBSDKSharePhoto *photo = [FBSDKSharePhoto photoWithImageURL:imageURL userGenerated:NO];
NSDictionary *properties = #{
#"og:type": #"abc-holdings:glc",
#"og:title": #"Sample GLC",
#"og:description": #"Test Geo",
#"og:url": #"http://samples.ogp.me/147425295593678",
#"og:image": #[photo],
#"abc-holdings:location:longitude":#(-58.381667),
#"abc-holdings:location:latitude":#(23.381667)
};
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
FBSDKShareOpenGraphAction *action = [FBSDKShareOpenGraphAction actionWithType:#"abc-holdings:has_a_glc" object:object key:#"glc"];
[action setString:#"true" forKey:#"fb:explicitly_shared"];
// Create the content
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = #"glc";
// Share the content
FBSDKShareAPI *shareAPI = [[FBSDKShareAPI alloc] init];
shareAPI.shareContent = content;
shareAPI.delegate = self;
[shareAPI share];
But this issue is that it respond me as below
Error Domain=com.facebook.sdk.share Code=201 "The operation couldn’t be completed. (com.facebook.sdk.share error 201.)" UserInfo=0x7fb9e1749190 {com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Error sharing Open Graph content, NSUnderlyingError=0x7fb9e14c5210 "The operation couldn’t be completed. (com.facebook.sdk.core error 8.)"}
Is there any idea to anyone regarding this ?
You should go to your app at Facebook. Choose Open Graph settings, choose your action type, scroll down till the end. There you will see some checkboxes Your action capabilities
Check last checkbox and try to share your content again.
After almost 2 days of reading through the Facebook docs, I still can't figure out why oh why my code for simply publishing a game victory does not work. If I use Facebook Sample's object, it does work (uncommented), but once I use the object, the app crashes and opens the browser (in simulator) and returns to the game again. The code is as follows:
NSDictionary *properties = #{
#"og:type": #"games.victory",
#"og:title": #"A Game Victory",
#"og:description": #"Awsum description",
};
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
// Create an action
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = #"games.celebrate";
[action setString:#"http://samples.ogp.me/500426766634310" forKey:#"victory"];
// [action setObject:object forKey:#"victory"];
// Create the content
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = #"victory";
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:nil];
What am I doing wrong and how can I fix this, I'm quite done with the FB documentation. Also, how could I know whether the story has been posted successfully in my app? Is there some delegate callback function or anything like that?
I am using the following code to share a picture and some message on the fb timeline using FBSDK open graph object and FBSDK open graph content.however the following code does nothing,no dialog is presented nor does it post anything to the timeline.am i missing anything in this code or does this code not work in the simulator?
- (IBAction)shareButtonPressed:(id)sender {
NSString *contentDesc=#"abcdcccdcc";
NSString *title=[NSString stringWithFormat:#"%# \n asd %#, asd %#",self.nameLabel.text,_fromDate.text,_toDate.text];
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = _profilePic.image;
photo.userGenerated = YES;
// Create an object
NSDictionary *properties = #{
#"og:type": #"memories.memory",
#"og:title":title ,
#"og:description":contentDesc
};
FBSDKShareOpenGraphObject *object = [FBSDKShareOpenGraphObject objectWithProperties:properties];
// Create an action
FBSDKShareOpenGraphAction *action = [[FBSDKShareOpenGraphAction alloc] init];
action.actionType = #"memories.view";
[action setObject:object forKey:#"memories.memory"];
// Add the photo to the action
[action setPhoto:photo forKey:#"image"];
// Create the content
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = #"memories.memory";
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:nil];
}
in the delegate method
-(void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
NSLog(#"%#",error);
}
the error log is printed as follows
Error Domain=com.facebook.sdk.share Code=2 "The operation couldn’t be completed. (com.facebook.sdk.share error 2.)" UserInfo=0x7faec97bb660 {com.facebook.sdk:FBSDKErrorArgumentValueKey=<FBSDKShareOpenGraphContent: 0x7faecbc16740>, com.facebook.sdk:FBSDKErrorDeveloperMessageKey=Feed share dialogs support FBSDKShareLinkContent., com.facebook.sdk:FBSDKErrorArgumentNameKey=shareContent}
change [action setPhoto:photo forKey:#"image"]; to [object setPhoto:photo forKey:#"og:image"];
2: fatuhoku - thank for your comment. You are right - i'm using FBSDKShareAPI. If i create photo with userGenerated set to YES it is attached like photo. The photo is placed in my album (which is automatically created) with the name of my app and the post type is 'photo'. If i use userGenerated set to NO the photo is placed in internal FB stage, the post is type 'link' but i can extract photo from the post property 'picture' and with some trick by changing two parameters in picture URL w=130 and h=130 get necessary size of my photo. All this i do with API not with Dialogs.