Posting attachments with Facebook Graph API using iPhone SDK

前端 未结 2 1646
野的像风
野的像风 2021-01-03 16:38

I\'ve been trying desperately to publish a message with an attachment to the current user\'s wall using Facebook\'s Graph API. I\'ve been successful at publishing a POST obj

相关标签:
2条回答
  • 2021-01-03 17:12

    To Publish FEED you have to use "USERID/feed"

    Eg: [facebook requestWithGraphPath:@"1231241/feed"
    andParams:params
    andHttpMethod:@"POST"
    andDelegate:self];

    and regarding the Properties, i dont think their is any properties with name "properties" is available for feed APIs.

    Check out here: http://developers.facebook.com/docs/reference/api/photo/

    0 讨论(0)
  • 2021-01-03 17:16

    OK, I found how to send properties together with my stream post. I discovered it by taking a look at the html in the actual Facebook Wall page. Turns out, the parameters for the POST object are considered the attachment so the only thing to be done is add the "properties" property directly to the POST parameters like this:

    NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:
                                @"property 1", @"PROP1",
                                @"property 2", @"PROP2",
                                nil];
    
    NSString *propStr = [jsonWriter stringWithObject:properties];
    
    
    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"post", @"type",
                               @"http://my.web.com/pic.png", @"picture",
                               @"http://my.web.com", @"link",
                               postName, @"name",
                               postCaption, @"caption",
                               postDescription, @"description",
                               postMessage, @"message",
                               propStr, @"properties",
                               nil];
    
    [_facebook requestWithGraphPath:@"me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];
    

    And voila! It worked!

    0 讨论(0)
提交回复
热议问题