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"];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With