2014-07-15 34 views
6

我想獲得使用Facebook的圖形版本方法的iOS的app_link_hosts,但我得到的錯誤消息。可以幫助我解決這個問題。 Facebook和App Link的文檔不清楚。獲取Facebook的應用鏈接的主機API

下面是代碼,

NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys: 
         @"app name", @"name", 
         theUrl, @"al:ios:url", 
         @"app store id", @"al:ios_id", 
         @"app name", @"al:ios:app_name", 
         @"{\"should_fallback\": false}", @"web", 
         fbAccessToken, @"access_token", 
         nil 
         ]; 

/* make the API call */ 

[FBRequestConnection startWithGraphPath:@"/(fb app id)/app_link_hosts" 
          parameters:params 
          HTTPMethod:@"POST" 
         completionHandler:^(
              FBRequestConnection *connection, 
              id result, 
              NSError *error 
             ) { 
          /* handle the result */ 
          NSLog(@"Result = %@",result); 
          if(error) NSLog(@"error = %@",error); 
         }]; 

這是我得到的錯誤,

error = Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x8c7d4b0 {com.facebook.sdk:HTTPStatusCode=403, com.facebook.sdk:ParsedJSONResponseKey={ 
body =  { 
    error =   { 
     code = 200; 
     message = "(#200) Permissions error"; 
     type = OAuthException; 
    }; 
}; 
code = 403; 
}, com.facebook.sdk:ErrorSessionKey=<FBSession: 0x9a53750, state: FBSessionStateOpen, loginHandler: 0x9a51fd0, appID: 443803585653119, urlSchemeSuffix: , tokenCachingStrategy:<FBSessionTokenCachingStrategy: 0x9a52960>, expirationDate: 2014-09-12 10:12:17 +0000, refreshDate: 2014-07-14 12:00:51 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:(
installed, 
"public_profile", 
"publish_actions", 
"user_friends" 
)>} 

回答

0

我的猜測是,你正在使用的「用戶訪問令牌」,而不是「應用程序令牌「這是生成應用程序鏈接所必需的。嘗試使用Graph api Explorer - https://developers.facebook.com/tools/explorer/(選擇應用程序令牌選項)生成測試鏈接,因爲從客戶端設備生成這不是一個好習慣。

相關問題