2013-08-02 126 views
1

請參閱12月29日更新的筆記在頁面底部時畫布URL錯誤。的iOS:張貼到牆上

您好我正在做其他人的iOS項目工作(這是一種靈魂破壞,因爲他們沒有記錄他們的代碼)maintanance工作。

的問題是,用戶登錄後,試圖分享訊息到牆上總是導致

錯誤100:「帖子的鏈接必須直接到應用程序的連接或帆布URL」。

我搜索在過去的2小時,適用於iOS還沒有找到任何結果明確(但很多WordPress的,這並沒有幫助)

任何想法可能會導致此。

這裏張貼在牆上的海外開發人員代碼:

-(void)uploadPropertyDetailsOnFacebookWall 
{ 


[FBSettings setLoggingBehavior:[NSSet setWithObjects:FBLoggingBehaviorFBRequests, FBLoggingBehaviorFBURLConnections, nil]]; 

NSString* photoURL = @""; 
NSString *[email protected]""; 
if (!kIsListOnce) { 
    photoURL = [currentItem objectForKey:@"Photo1FeaturedURL"]; 
    strFullPropertyDetailLink=[currentItem objectForKey:@"FullDisplayLink"]; 
} 
else { 
    strFullPropertyDetailLink=[currentItem objectForKey:@"FullDisplayLink"]; 
    NSArray* list = [[currentItem objectForKey:@"objects"] objectForKey:@"img_small"]; 
    ; 
    if ([list count] > 0) { 
     photoURL = [list objectAtIndex:0]; 
    } 

} 

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 

NSString *strLinkOfApp=(NSString *)[Utils config:KiTunesstoreAppLink]; //strFullPropertyDetailLink, 
NSDictionary *postParams = 
[[NSMutableDictionary alloc] initWithObjectsAndKeys: 


strFullPropertyDetailLink, @"link", 
photoURL, @"picture", 
[Utils config:kTextAgentName], @"name", 
strAddress, @"caption", 
[currentItem objectForKey:@"Description"], @"description", 
nil]; 



[FBRequestConnection startWithGraphPath:@"me/feed" 
          parameters:postParams 
          HTTPMethod:@"POST" 
         completionHandler:^(FBRequestConnection *connection, 
              id result, 
              NSError *error) 
{ 
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; 

    NSString *alertText; 

    NSLog(@"%@",error); 


    if (error) { 

     NSDictionary *dict=[error userInfo]; 
     NSLog(@"%@",dict); 

     NSDictionary *dictJSON=[dict objectForKey:@"com.facebook.sdk:ParsedJSONResponseKey"]; 
     NSDictionary *dictBody=[dictJSON objectForKey:@"body"]; 
     NSDictionary *dictError=[dictBody objectForKey:@"error"]; 

     NSString *strCode=[[dictError objectForKey:@"code"] description]; 

     if([strCode isEqualToString:@"200"]) 
     { 
      alertText = @"You have not authorized the application to perform this publish action"; 
     }else{ 
     alertText = [@"An error ocurred: " stringByAppendingString:error.description]; 
      alertText=[alertText stringByAppendingString: strFullPropertyDetailLink]; 
     } 
    } else { 
     alertText = [NSString stringWithFormat: 
         @"Property details has been successfully shared on your Facebook Wall"]; 

    } 
    [[[UIAlertView alloc] initWithTitle:@"Result" 
           message:alertText 
           delegate:nil 
         cancelButtonTitle:@"OK!" 
         otherButtonTitles:nil] show]; 
    // Show the result in an alert 

}]; 

} 

這是我不斷收到錯誤:

Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed(com.facebook.sdk     error 5.)" UserInfo=0x1d548710 {com.facebook.sdk:ParsedJSONResponseKey={ 
body =  { 
    error =   { 
     code = 100; 
     message = "(#100) The post's links must direct to the application's connect or canvas URL."; 
     type = OAuthException; 
    }; 
}; 
code = 400; 
}, com.facebook.sdk:HTTPStatusCode=400} 
2013-08-02 12:06:12.806 RealEstate[385:907] { 
"com.facebook.sdk:HTTPStatusCode" = 400; 
"com.facebook.sdk:ParsedJSONResponseKey" =  { 
    body =   { 
     error =    { 
      code = 100; 
      message = "(#100) The post's links must direct to the application's connect or canvas URL."; 
      type = OAuthException; 
     }; 
    }; 
    code = 400; 
}; 
} 

請幫幫忙,我已經做了更多的研究在線自我最初的帖子,仍然無法找到答案。

更新12月17日:

  • 我使用SDK 3.1.1。我想避免更新,因爲我維護着別人的代碼。

  • 使用我/進料,在一個fbrequestconnection,任何額外paramater除了「消息」,崩潰的應用程序。

  • 我也嘗試應用與其他堆棧溢出的用戶建議的設置鏈接到一個測試帳戶viewable here

  • 我也禁用後流安全

其他問題

  • 我錯過了將應用程序連接到Facebook的東西嗎?
  • 爲什麼不會它檢測到「鏈接」參數是一樣的帆布網址是什麼?

回答

1

我一直在掙扎張貼到Facebook塗鴉牆了。

爲什麼不使用facebook SDK而不是API? 有兩種方式發佈到Facebook塗鴉牆使用SDK

通過Feed Dialog 或 通過Share Dialog

飼料對話是很容易實現,你可以控制你想通過你發送的參數作什麼崗位,唯一不好的是參數是有限的。

Share對話框使用OpenGraph,並要求用戶安裝facebook應用程序,您還必須在Facebook的應用程序開發者頁面中創建一個操作,以便您的應用程序知道如何處理該操作。 好的部分是,你可以分享幾乎所有你想要的。

我建議你檢查Feed對話框,如果你想要一個簡單的Facebook分享,這是最簡單的方法。

編輯

NSString *message = [NSString stringWithFormat:@"%@%@/%@",domain,TypeName,[object alias]]; 

    // Put together the dialog parameters 

    NSMutableDictionary *params = 

    [NSMutableDictionary dictionaryWithObjectsAndKeys: 

    @"TITLE", @"description", 

    message, @"link", 

    [object image],@"picture", 

    nil]; 

    // Invoke the dialog 

    [FBWebDialogs presentFeedDialogModallyWithSession:nil 

             parameters:params 

              handler: 

    ^(FBWebDialogResult result, NSURL *resultURL, NSError *error) { 

     if (error) { 

     // Error launching the dialog or publishing a story. 

     //NSLog(@"Error publishing story."); 

     } else { 

      if (result == FBWebDialogResultDialogNotCompleted) { 

       // User clicked the "x" icon 

       //NSLog(@"User canceled story publishing."); 

      } else { 

       // Handle the publish feed callback 

       NSDictionary *urlParams = [self parseURLParams:[resultURL query]]; 

       if (![urlParams valueForKey:@"post_id"]) { 

        // User clicked the Cancel button 

        //NSLog(@"User canceled story publishing."); 

       } else { 

        // User clicked the Share button 

        NSString *msg = @"Partilhado com sucesso"; 

        //NSLog(@"%@", msg); 

        // Show the result in an alert 

        [[[UIAlertView alloc] initWithTitle:@"Aviso" 

               message:msg 

               delegate:nil 

             cancelButtonTitle:@"OK!" 

             otherButtonTitles:nil] 

         show]; 

       } 

      } 

     } 

    }]; 
+0

我沒有獲得飼料對話,代碼使用SDK 3.1.1 –

+0

我Eddited與我使用一些代碼的aswer。檢查是否可以更新sdk,儘管我相信Feed對話框在該版本中可用。 –