I have to replace using Facebook SDK from v3.x to v4.x in my application. When it used old sdk with next code:
NSString *msg = [NSString stringWithFormat:@"%@\n%@\n%@", petition.petition_name, petition.recipient, petition.content];
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
msg, @"message",
petition.uri ? petition.uri : [NSURL URLWithString:SITE], @"link",
nil
];
NSLog(@"%@\n%@", msg, params);
[FBRequestConnection startWithGraphPath:@"me/feed"
parameters:params
HTTPMethod:@"POST"
completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
. . . .
}];
string variable msg passed text message when post was sharing:
In Facebook SDK 4.x there is a special dialog that have no any field or function for such task. I use next code (even with og:- params - even there is og:message i've tried), but my post appeared with no message:
FBSDKSharePhoto *photo = [[FBSDKSharePhoto alloc] init];
photo.image = [self.pdata.imagesArr firstObject];
// 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;
NSString *urlStr = [NSString stringWithFormat:@"%@/api/images/%@?width=%f&height=%f&x=0&y=0&resize=1", K_BASE_URL, [[self.pdata.imagesArr firstObject] image_id], K_PETITION_IMAGE_WIDTH, K_PETITION_IMAGE_HEIGHT];
// Create an object
NSDictionary *properties = @{
@"og:type": @"books.book",
@"og:title": self.pdata.petition_name,
@"og:description": self.pdata.content,
@"og:image": urlStr,
@"og:url": [NSURL URLWithString:self.pdata.uri],
@"og:message": @"QQQQQQQWW",
@"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"];
// Create the content
FBSDKShareOpenGraphContent *content = [[FBSDKShareOpenGraphContent alloc] init];
content.action = action;
content.previewPropertyName = @"books:book";
[FBSDKShareDialog showFromViewController:self
withContent:content
delegate:nil];
This message can be passed to the wall only from system facebook dialog ShareDialog, but user has to input message manually:
So i have two questions:
1) Can I share my post even without this FBSDKShareDialog? Is it possible?
2) If first == false - how can pass message to post through dialog programmatically?
Thanks in advance!