【问题标题】:Facebook friend's wall posting through IDFacebook朋友通过ID发贴
【发布时间】:2012-11-07 20:35:49
【问题描述】:

我正在尝试在 Facebook 朋友的墙上发帖,我尝试了这两种方法,但都不起作用:

1.

//post on wall
NSMutableDictionary *variables = [[NSMutableDictionary alloc]initWithCapacity:1];
[variables setObject:@"v" forKey:@"message"];

[graphref doGraphPost:[NSString stringWithFormat:@"1389799421/feed"] withPostVars:variables];
//post on wall

2.

 [_facebook requestWithGraphPath:@"1389799421/feed"
                      andParams:[NSMutableDictionary dictionaryWithObject:@"test wall post" forKey:@"message"]
                  andHttpMethod:@"POST"
                    andDelegate:self];

...我不明白为什么!在 facebook 网站上,我添加了捆绑包和权限。

【问题讨论】:

  • 我不认为 facebook 对编写程序自动发布到墙上的人很友好。你在这里打一场艰苦的战斗......除了生成垃圾邮件之外,你还有什么目的呢????
  • 您是否只是想将裸帖发送到 facebook 服务器并期望它实际发布到墙上?如果是这样,你离让它发挥作用还很遥远。在尝试发送此帖子之前,您如何验证您的连接/会话?
  • 好吧,我使用最初的 HelloFacebook 示例登录了 facebook。我知道这不是最好的解决方案,但重点是,据我了解,无法发送消息,并且没有任何用于 facebook 请求的示例代码!

标签: ios xcode facebook


【解决方案1】:

我正在尝试在 Facebook 朋友的墙上发帖

Facebook 最近在开发者博客中宣布,通过 API will not be possible any more from Feb 2013 on 发布到另一个用户的墙:

移除通过 Graph API 向朋友墙发帖的功能

我们将取消通过 Graph API 在用户朋友的墙上发帖的功能。具体来说,针对 [user_id]/feed 的 [user_id] 与会话用户不同的帖子,或 target_id 用户与会话用户不同的 stream.publish 调用将失败。如果您想允许人们发布到他们朋友的时间线,请调用feed dialog

所以我认为现在开始开发这样的功能是没有用的。

【讨论】:

    【解决方案2】:

    首先,您必须以发布权限打开会话。具体来说,您必须请求publish_stream 权限。

    NSArray * permissions = [[NSArray alloc] initWithObjects:@"publish_stream", nil];
    return [FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceFriends allowLoginUI:YES completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
      [self sessionStateChanged:session
                          state:status
                          error:error];
    }]; 
    

    如果您具有发布权限,则可以创建和发送请求。确保包含access_token 作为参数之一。否则,您将收到身份验证错误。

    NSDictionary * postParameters = [NSDictionary dictionaryWithObjectsAndKeys:_textView.text, @"message", FBSession.activeSession.accessToken, @"access_token", nil];
    NSString * graphPath = @"ID_NUMBER_HERE/feed";
    FBRequest * request = [FBRequest requestWithGraphPath:graphPath parameters:postParameters HTTPMethod:@"POST"];
    [[request initWithSession:FBSession.activeSession graphPath:graphPath parameters:postParameters HTTPMethod:@"POST"] startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
      NSLog(@"Successful posted to Facebook");
      }];
    }
    

    【讨论】:

    • 另外,正如 CBroe 所指出的,您现在不希望构建此 API 调用,因为它很快就会消失。
    猜你喜欢
    • 1970-01-01
    • 2012-04-27
    • 1970-01-01
    • 2013-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-05
    • 1970-01-01
    相关资源
    最近更新 更多