【问题标题】:Facebook attachment data format for "media" key. (related to Posting Image+Text on friend's wall )“媒体”键的 Facebook 附件数据格式。 (关于在朋友的墙上张贴图片+文字)
【发布时间】:2011-09-06 12:51:41
【问题描述】:

我正在尝试从我的朋友列表中向其中一位朋友发布一些数据。 我可以在我朋友的墙上发布一些文字。但它无法发布图像和其他数据。 (目前我只能看到关键“消息”的文本,其余部分没有出现在帖子中。

SBJSON *jsonWriter = [[SBJSON new] autorelease];

/*
 Action LInks
 */
NSDictionary* actionLinks = [NSArray arrayWithObjects:[NSDictionary dictionaryWithObjectsAndKeys:
                                                       @"Always Running",@"text",@"http://itsti.me/",@"href", nil], nil];
//Json Object Conversion
NSString *actionLinksStr = [jsonWriter stringWithObject:actionLinks];


/*
 Media Data in this case an image.
*/
**NSMutableDictionary *dictMedia=[NSMutableDictionary dictionaryWithObjectsAndKeys:@"image",@"type",@"http://www.facebook.com/images/devsite/iphone_connect_btn.jpg",@"src",@"www.fizzysoftware.com",@"href", nil];
NSArray *mediaArray=[[NSArray alloc] initWithObjects:dictMedia, nil];
NSString *mediaJsonString=[jsonWriter stringWithObject:mediaArray]; // error:actionLinksStr] 

//Attatchment Data :Include media data,action link etc.

NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
                            @"First Title", @"name",
                            @"This is the subtitle", @"caption",
                            @"This is is description", @"description",
                           mediaJsonString, @"media", nil];

//Json conversion of the attachment data.
NSString *attachmentStr = [jsonWriter stringWithObject:attachment];**

//Main parameter
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"Share on Facebook",  @"message",
                               actionLinksStr, @"action_links",
                               attachmentStr, @"attachment",
                               nil];

 //Post to friend's wall, whose uid is friend_uid
[ _facebook requestWithGraphPath:[NSString stringWithFormat:@"friend_uid/feed/"] andParams:params
 andHttpMethod:@"POST" andDelegate:self];

我在发送附件时出错的任何建议。我只能在我的帖子中看到 param 的“消息”部分,并且帖子中没有显示任何附件数据。 提前致谢。

【问题讨论】:

    标签: iphone ios facebook ios4 facebook-graph-api


    【解决方案1】:

    您可以尝试使用新方法打开提要对话框,并将“to”(以前是目标)参数与其余附件一起直接设置为参数。

      NSDictionary* params = [NSDictionary dictionaryWithObjectsAndKeys:
                                 @"some facebook id", @"to",
                                 @"http://yourpage.com", @"link",
                                 @"http://yourpage.com/image.png", @"picture",
                                 @"the name", @"name",
                                 @"the caption", @"caption",
                                 @"the description", @"description",
                                 nil];
      [_facebook dialog: @"feed" andParams: params andDelegate: self];
    

    这里有一些关于提要对话框的文档。

    http://developers.facebook.com/docs/reference/dialogs/feed/

    如果你是直接发帖,你应该这样做:

    [_facebook requestWithGraphPath:@"some facebook id/feed"
                          andParams:params 
                      andHttpMethod:@"POST" 
                        andDelegate:self];
    

    关于直接帖子的文档: http://developers.facebook.com/docs/reference/api/user/#posts

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多