【问题标题】:How to share location on Facebook along with message using https://graph.facebook.com/me/feed如何使用 https://graph.facebook.com/me/feed 在 Facebook 上共享位置以及消息
【发布时间】:2013-12-02 13:05:36
【问题描述】:

是否可以使用 iOS SLRequest 和图形 API "https://graph.facebook.com/me/feed" ,..在 Facebook 墙上发布带有位置的消息?

我已经实现了如下的 SLRequest,

                        SLRequest *feedRequest = [SLRequest
                                               requestForServiceType:SLServiceTypeFacebook
                                               requestMethod:SLRequestMethodPOST
                                               URL:https://graph.facebook.com/me/feed
                                               parameters:@{@"message": @"text message with location",@"link":@"www.google.com",@"place":@"Road No 19, Mumbai"}];

使用 ACFacebookPermissionsKey:@[@"publish_stream", @"publish_actions"], 返回 500 状态错误。

谢谢。

【问题讨论】:

  • 除了 500 错误之外还有更多信息吗?您的“地点”参数无效。它需要是地点页面的 ID,而不仅仅是地址。请参阅此处的 /feed 文档developers.facebook.com/docs/graph-api/reference/user/feed
  • @Ming Li - 没有错误,只是响应状态为 500。关于您上面提到的 /feed 文档,您能否建议一个示例代码 sn-p如何获取地点页面的 ID。
  • 要获取地点页面的 id,假设您想要西雅图太空针塔的 id,这里是 Facebook 页面:facebook.com/spaceneedle,只需将 'www' 替换为 'graph',然后向graph.facebook.com/spaceneedle 发出请求,您将看到一个“id”属性。
  • @user2020789 你找到解决这个问题的方法了吗?如果是,那么您可以发布代码吗?

标签: ios facebook facebook-graph-api


【解决方案1】:

500 内部服务器错误是“服务器端”错误,这意味着问题不在于您的 PC 或 Internet 连接,而是网站服务器的问题。

使用它集成到您​​的代码中以共享位置 https://developers.facebook.com/docs/ios/placepicker-ui-control/

使用此方法发布提要:-

-(IBAction)postFBMessage:(id)sender
{
    // Create the URL to the end point
    NSURL *postURL = [NSURL URLWithString:@"https://graph.facebook.com/me/feed"];

    NSString *link = @"http://developer.apple.com/library/ios/#documentation/Social/Reference/Social_Framework/_index.html%23//apple_ref/doc/uid/TP40012233";
    NSString *message = @"Testing Social Framework";
    NSString *picture = @"http://www.stuarticus.com/wp-content/uploads/2012/08/SDKsmall.png";
    NSString *name = @"Social Framework";
    NSString *caption = @"Reference Documentation";
    NSString *description = @"The Social framework lets you integrate your app with supported social networking services. On iOS and OS X, this framework provides a template for creating HTTP requests. On iOS only, the Social framework provides a generalized interface for posting requests on behalf of the user.";

    NSDictionary *postDict = @{
    @"link": link,
    @"message" : message,
    @"picture" : picture,
    @"name" : name,
    @"caption" : caption,
    @"description" : description
    };

    SLRequest *postToMyWall = [SLRequest requestForServiceType:SLServiceTypeFacebook requestMethod:SLRequestMethodPOST URL:postURL parameters:postDict];

    FacebookAccountManager* sharedManager = [FacebookAccountManager sharedAccount];
    [postToMyWall setAccount:sharedManager.facebookAccount];

    [postToMyWall performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error)
    {
        if (error) {
            // If there is an error we populate the error string with error
            _errorString = [NSString stringWithFormat:@"%@", [error localizedDescription]];

            // We then perform the UI update on the main thread. All UI updates must be completed on the main thread.
            [self performSelectorOnMainThread:@selector(updateErrorString) withObject:nil waitUntilDone:NO];
        }

        else
        {
            NSLog(@"Post successful");
            NSString *dataString = [[NSString alloc] initWithData:responseData encoding:NSStringEncodingConversionAllowLossy];
            NSLog(@"Response Data: %@", dataString);
        }
     }];
}

【讨论】:

  • ,我已使用您上面建议的方法发布提要,但我的实际要求是发送位置(或地点)作为参数以及 /me 的(链接、消息)等其他参数/feed API。
猜你喜欢
  • 1970-01-01
  • 2023-03-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多