suj*_*406 5 facebook facebook-graph-api ios facebook-ios-sdk
我使用以下代码在fb时间轴上使用FBSDK开放图形对象和FBSDK打开图形内容共享图片和一些消息.但是下面的代码什么也没做,没有对话框,也没有发布任何内容到timeline.am我缺少此代码中的任何内容或此代码在模拟器中不起作用?
- (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];
}
Run Code Online (Sandbox Code Playgroud)
在委托方法中
-(void)sharer:(id<FBSDKSharing>)sharer didFailWithError:(NSError *)error
{
NSLog(@"%@",error);
}
Run Code Online (Sandbox Code Playgroud)
错误日志打印如下
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}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5416 次 |
| 最近记录: |