iOS上的Facebook连接 - 图片不显示墙贴 [英] Facebook Connect on iOS - Picture doesn't display with wall post

查看:118
本文介绍了iOS上的Facebook连接 - 图片不显示墙贴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Facebook提供的演示项目与我的应用程序建立了Facebook连接。一切都很好,除了最后一个小步骤...




  • 首先,我登录并获得权限。


  • 接下来,我上传了一张照片。这很好,我可以看到我的Facebook相册中的图片,就像我应该能够。


  • 当这张图片上传时,我得到它的URL由FBRequest代表)。将此网址复制到网页浏览器中,可以直接将图片提供给我,因此我知道这个网址是正确的。




以下是问题所在:




  • 我现在想在墙上贴上这张照片。墙上的帖子很好,但图片似乎没有附加,状态作为纯文本留言。



这是我最后一部分使用的代码:

   - (void)request((FBRequest *)request didLoad :( id)result {

NSString * picUrl = [result objectForKey:@src_big]; //这绝对返回正确的URL

if(picUrl)
{
NSString * message = @测试状态;
NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
message,@message,picUrl,@picture,@看我的照片,@name,nil];

[facebook requestWithMethodName:@facebook.Stream.publishandParams:params
andHttpMethod:@POSTandDelegate:self];
}
}

任何想法我失踪或做错了?

解决方案

使用以下代码修复(经过大量失败的尝试)。 Facebook不喜欢我尝试的方式,您只需一步就可以完成所有操作:

  NSData * imageData = UIImagePNGRepresentation(image); 

NSMutableDictionary * params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
@Test message,@message,imageData,@source,nil];

[facebook requestWithGraphPath:@/ me / photosandParams:params andHttpMethod:@POSTandDelegate:self];


I've set up Facebook connect with my app using the demo project provided by Facebook. Everything works great, except for the last little step...

  • First of all, I login and get permissions.

  • Next, I upload a picture. This works great, I can see the picture in my Facebook album like I should be able to.

  • When this picture is uploaded, I get it's URL (returned by the FBRequest delegate). Copy pasting this URL into a web browser takes me directly to the image, so I know that this URL is correct.

Here's where the problem is:

  • I now want to present this picture alongside a wall post. The wall post is fine, but the picture just doesn't seem to attach and the status is left as a plain text message.

Here's the code I'm using for the last part:

- (void)request:(FBRequest *)request didLoad:(id)result {

    NSString* picUrl = [result objectForKey:@"src_big"];  //this definitely returns the right URL

    if (picUrl)
    {
        NSString *message = @"Test status";
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       message, @"message", picUrl, @"picture", @"Look at my photo", @"name", nil];

        [facebook requestWithMethodName:@"facebook.Stream.publish" andParams:params
                          andHttpMethod:@"POST" andDelegate:self];
    }
}

Any ideas what I'm missing or doing wrong?

解决方案

Fixed with the following code (after a lot of failed attempts). Facebook doesn't like the way I was trying it, you've got to do it all in just one step:

NSData *imageData = UIImagePNGRepresentation(image);

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"Test message", @"message", imageData, @"source", nil];

[facebook requestWithGraphPath:@"/me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];

这篇关于iOS上的Facebook连接 - 图片不显示墙贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆