【问题标题】:Facebook SDK iOS: Add post to feed with imageFacebook SDK iOS:将帖子添加到带有图像的提要
【发布时间】:2011-12-05 07:37:07
【问题描述】:

我已经知道如何将帖子添加到我的用户供稿中,但目前它需要使用图片 URL:

// The action links to be shown with the post in the feed
NSArray* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
                                                  self.title,@"name",self.url,@"link", nil], nil];
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];

// Dialog parameters
NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               self.title, @"name",
                               @"Created using My App.", @"caption",
                               @"Check out the thing I just uploaded!", @"description",
                               self.url, @"link",
                               @"http://www.facebookmobileweb.com/hackbook/img/facebook_icon_large.png", @"picture",
                               actionLinksStr, @"actions",
                               nil];

[facebook dialog:@"feed" andParams:params andDelegate:self];

我想上传UIImage。我看到有些人谈论为此使用graph api。我将如何做到这一点并且仍然能够使用标题、标题和消息?

【问题讨论】:

    标签: ios facebook cocoa-touch facebook-graph-api


    【解决方案1】:

    用这两行替换你的四行代码:

    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:YourUIImage, @"source",@"caption description",@"message",  nil];
    
    [facebook requestWithGraphPath:[NSString stringWithFormat:@"/me/photos?access_token=%@", facebook.accessToken] andParams:params andHttpMethod:@"POST" andDelegate:self];
    

    和你的 UIImage 的“YourUIImage”。 希望我回答了你的问题!

    【讨论】:

    • 非常感谢您的回答,对我帮助很大。我想指出的是,在当前的 Facebook SDK(我使用的是 3.1.1)中,有新的 Graph API,但很清楚需要进行哪些更改才能使您的解决方案正常工作。
    • 很高兴它帮助了你!是的,我的回答是 10 个月前,SDK 可以改变很多东西! :)
    猜你喜欢
    • 2012-09-04
    • 1970-01-01
    • 1970-01-01
    • 2016-04-29
    • 2013-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多