问题
I am trying to run an example of a facebook provided Open Graph Action but nothing happens. When debugging I see that action is created but at [FBDialogs presentShareDialog...] it just skips over and jump to the end of the function. Why do you think this is? I read that the sharedialog cant run in the IOS simulator but shouldn't produce an error or something? Or if I run it on the simulator should nothing acctually happen?
-(IBAction)ShareFB:(id)sender{
id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
[action setObject:@"https://example.com/book/Snow-Crash.html" forKey:@"book"];
[FBDialogs presentShareDialogWithOpenGraphAction:action
actionType:@"books.reads"
previewPropertyName:@"book"
handler:^(FBAppCall *call, NSDictionary *results, NSError *error) {
if(error) {
NSLog(@"Error: %@", error.description);
} else {
NSLog(@"Success!");
}
}];
reference text: https://developers.facebook.com/docs/ios/share-dialog/#tips
回答1:
I have zero iOS dev experience, but it looks like that example is using a Self-Hosted Object, meaning the Open Graph object definitions are found in HTML markup specified in a particular URL that the Facebook server fetches and parses. Your example is looking for some "book" object at https://example.com/book/Snow-Crash.html
It looks like this was a simple URL for example sake and does not contain any of the actual Open Graph properties for a 'book.' There's a tool available from Facebook to read URLs and see what Facebook looks for and gets when concerned with Open Graph objects: https://developers.facebook.com/tools/debug/og/object?q=https%3A%2F%2Fexample.com%2Fbook%2FSnow-Crash.html
Basically, you will need to have a website set up and define the object at a specific URL with some specific Meta Tags. Read up on here for more information on this: https://developers.facebook.com/docs/opengraph/using-objects/
来源:https://stackoverflow.com/questions/19527976/open-graph-action