[英]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.