开发者

Facebook attachment data format for "media" key. (related to Posting Image+Text on friend's wall )

开发者 https://www.devze.com 2023-04-03 03:33 出处:网络
I am trying to post some data at one of the friend from my f开发者_JS百科riend list . I am able to post some text on my friend\'s wall.But it fails to post the image and other data . (Presentl I can

I am trying to post some data at one of the friend from my f开发者_JS百科riend list . I am able to post some text on my friend's wall.But it fails to post the image and other data . (Presentl I can only see the text for key "message" and rest of the part does not appear in the post.

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];

Any suggestions where I am mistaking in sending the attachment. I am able to only see the "message" part of the param in my post and none of the attachment data is shown in the post. Thanks in advance.


You can try using the new approach to open a feed dialog and set the "to" (used to be target) parameter along with the rest of the attachments directly as params.

  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];

Here you have some documentation regarding the feed dialog.

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

If you are posting directly, you should be doing something like this:

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

Doc regarding direct posts: http://developers.facebook.com/docs/reference/api/user/#posts

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号