[英]Facebook SDK for iOS post on wall using open graph API
我正在尝试在我的Facebook页面上发布一条消息,它可以正常工作,但该帖子仅对我可见。 我的朋友看不到! 似乎它不是“公共”的。
我已经设置了defaultAudience:FBSessionDefaultAudienceEveryone
因此它应该发布给所有人,不仅限于我。
这是我的代码:
-(void)postOnFacebook
{
if (FBSession.activeSession.isOpen)
[self postOnWall];
else
{
[FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObjects:@"publish_actions", nil]
defaultAudience:FBSessionDefaultAudienceEveryone
allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error)
{
if (error)
NSLog(@"Login failed");
else if (FB_ISSESSIONOPENWITHSTATE(status))
[self postOnWall];
}];
};
}
- (void)postOnWall
{
FBRequestConnection *newConnection = [[FBRequestConnection alloc] init];
FBRequestHandler handler =
^(FBRequestConnection *connection, id result, NSError *error) {
[self requestCompleted:connection forFbID:@"me" result:result error:error];
};
NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
@"pippo", @"message",
nil];
FBRequest *request=[[FBRequest alloc] initWithSession:FBSession.activeSession graphPath:@"me/feed" parameters:params HTTPMethod:@"POST"];
[newConnection addRequest:request completionHandler:handler];
[requestConnection cancel];
requestConnection = newConnection;
[newConnection start];
}
一个可能的原因可能是您的应用程序处于开发模式 ,因此您使用此应用程序发表的帖子仅对添加的开发人员/测试人员可见。
所以你可以做两件事-
从开发模式中删除该应用程序并将其启用。
将一些朋友添加为测试人员/开发人员/管理员。
需要授予您的应用访问Facebook的权限。
[FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObjects:@"publish_actions","email",@"friends_location",@"status_update",@"publish_stream", nil]
defaultAudience:FBSessionDefaultAudienceEveryone
allowLoginUI:YES
completionHandler:^(FBSession *session,
FBSessionState status,
NSError *error)
希望这对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.