【问题标题】:Facebook share dialog does not post story with local imageFacebook 分享对话框不会发布带有本地图片的故事
【发布时间】:2014-07-29 00:34:27
【问题描述】:

我正在尝试使用带有代码的共享对话框发布故事:

[FBDialogs presentShareDialogWithOpenGraphAction:action
                                      actionType:@"myApp:myActionType"
                             previewPropertyName:@"myObjectType"
                                         handler:^(FBAppCall *call, NSDictionary *results, NSError *error)
{
    if(error)
    {
        NSLog(@"Facebook: error publishing story: %@", error.description);
    }
    else
    {
        NSLog(@"Facebook: publishing story: result %@", results);
    }
}];

我得到共享对话框(显示图像预览)并按Post,然后我得到进度条但它没有进展,然后我切换回我的应用程序。不仅如此,处理程序不会被调用。我正在尝试使用本地生成的图像发布一个故事,如下所示:

id<FBOpenGraphAction> action = (id<FBOpenGraphAction>)[FBGraphObject graphObject];
NSArray* image = @[ @{@"url": [UIImage imageNamed:@"image-poof-1.png"], @"user_generated": @"true"} ];
[action setObject:image forKey:@"image"];

id<FBGraphObject> object = [FBGraphObject openGraphObjectForPost];
[object setObject:@"myApp:myObjectType" forKey:@"type"];
[object setObject:@"my title" forKey:@"title"];
[object setObject:@"my description" forKey:@"description"];

[action setObject:object forKey:@"myObjectType"];

我尝试使用指向网络上的图片的链接进行发布,并且成功了。

编辑:我关注了this facebook code example

【问题讨论】:

    标签: ios facebook-graph-api


    【解决方案1】:

    我认为属性 url 仅用于图像 url 尝试发布文件:

        NSMutableDictionary *variables = [NSMutableDictionary dictionaryWithCapacity:2];
        UIImage *picture = [UIImage imageNamed:@"75x75.png"];
        FbGraphFile *graph_file = [[FbGraphFile alloc] initWithImage:picture];
        [variables setObject:graph_file forKey:@"file"];
        [variables setObject:@"this is a test message: postPictureButtonPressed" forKey:@"message"];
        //the fbGraph object is smart enough to recognize the binary image data inside the FbGraphFile
        //object and treat that is such.....
        FbGraphResponse *fb_graph_response = [fbGraph doGraphPost:@"117795728310/photos" withPostVars:variables];
    

    阅读全文

    Document

    Sample app

    【讨论】:

    【解决方案2】:

    我没有分享对话框发布本地图片的经验,但我已将本地图片发布到 Facebook,但没有分享对话框。并成功发布了图片和消息。我的代码是

    NSString *message=@"your message";
    UIImage *sendPic = [UIImage imageNamed:@"image.png"];
        NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
        [params setObject:message forKey:@"message"];
        [params setObject:UIImagePNGRepresentation(sendPic) forKey:@"picture"];
        //fbShreBtn.enabled = NO; //for not allowing multiple hits
        [FBSession setActiveSession:[self appDelegate].session];
    
        [FBRequestConnection startWithGraphPath:@"me/photos"
         parameters:params
         HTTPMethod:@"POST"
         completionHandler:^(FBRequestConnection *connection,
         id result,
         NSError *error)
         {
             NSLog(@"fb result : %@",result);
             if (error)
             {
                 //showing an alert for failure
                 NSLog(@"error : %@",error);
                 UIAlertView *alertView = [[UIAlertView alloc]
                                           initWithTitle:@"Post Failed"
                                           message:error.localizedDescription
                                           delegate:nil
                                           cancelButtonTitle:@"OK"
                                           otherButtonTitles:nil];
                 [alertView show];
    
             }
             else
             {
                 //showing an alert for success
                 UIAlertView *alertView = [[UIAlertView alloc]
                                           initWithTitle:@"Post success"
                                           message:@"Shared successfully"
                                           delegate:nil
                                           cancelButtonTitle:@"OK"
                                           otherButtonTitles:nil];
                 [alertView show];
    
             }
             //fbShreBtn.enabled = YES;
         }];
    

    它可能对你有用。谢谢。

    【讨论】:

      猜你喜欢
      • 2014-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多