2013-12-20 26 views
1

我正嘗試使用Facebook iOS SDK中的Graph API。使用Facebook iOS SDK發佈運行操作

到目前爲止,我管理,以簡單的發佈狀態更新使用:

[connection addRequest:[FBRequest requestForPostStatusUpdate:@"Test" 
    completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 
     if (error) [self.appDelegate showUnknownCommunicationError]; 
    }]; 
[connection start]; 

接下來我試着用provided sample:

NSMutableDictionary<FBGraphObject> *action = [FBGraphObject graphObject]; 
action[@"course"] = @"http://samples.ogp.me/136756249803614"; 

[FBRequestConnection startForPostWithGraphPath:@"me/fitness.runs" 
            graphObject:action 
          completionHandler:^(FBRequestConnection *connection, 
               id result, 
               NSError *error) { 
           // handle the result 
          }]; 

這不會引發任何錯誤後運行的動作,但還沒有出現在我的牆上。我認爲這是因爲,從這個樣本應用程序id不符合我的,所以我試圖建立自己當然像這樣:

NSMutableDictionary<FBGraphObject> *action = [FBGraphObject graphObject]; 

action[@"fb:app_id"] = FB_APP_ID; 
action[@"og:type"] = @"fitness.course"; 
action[@"og:title"] = @"Sample Course"; 
action[@"og:image"] = @"https://s-static.ak.fbcdn.net/images/devsite/attachment_blank.png"; 
action[@"og:description"] = @"Test description"; 
action[@"og:url"] = @"https://mysite.pl/"; 

這將引發錯誤,並說,我的目標缺乏課程屬性。我現在很困惑...

爲我的應用程序運行的行動還沒有revieved,但我想這不是點,因爲我用我的開發人員帳戶進行測試。

編輯。我噸原木從Facebook記錄:

FBSDKLog: Request <#1111>: 
    URL: https://graph.facebook.com 
    Method: POST 
    UserAgent: FBiOSSDK.3.10.0 
    MIME: multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f 
    Body (w/o attachments): 
    batch_app_id: 1409052495999988 
    batch: [{"method":"POST","relative_url":"me\/fitness.runs?sdk=ios&migration_bundle=fbsdk%3A20131015&format=json&access_token=ACCESS_TOKEN_REMOVED","body":"course=http%3A%2F%2Fsamples.ogp.me%2F136756249803614"},{"method":"GET","relative_url":"method\/auth.extendSSOAccessToken?sdk=ios&migration_bundle=fbsdk%3A20131015&format=json&access_token=ACCESS_TOKEN_REMOVED"}] 

2013-12-23 09:28:53.756 RunGuru[1559:60b] FBSDKLog: Response <#1111> 
Duration: 1551 msec 
Size: 1672 kB 
Response Body: 
(
     { 
     body =   { 
      id = 10201708817820717; 
     }; 
     code = 200; 
     headers =   (
         { 
       name = "Access-Control-Allow-Origin"; 
       value = "*"; 
      }, 
         { 
       name = "Cache-Control"; 
       value = "private, no-cache, no-store, must-revalidate"; 
      }, 
         { 
       name = Connection; 
       value = close; 
      }, 
         { 
       name = "Content-Type"; 
       value = "text/javascript; charset=UTF-8"; 
      }, 
         { 
       name = Expires; 
       value = "Sat, 01 Jan 2000 00:00:00 GMT"; 
      }, 
         { 
       name = Pragma; 
       value = "no-cache"; 
      }, 
         { 
       name = "x-fb-loadmon"; 
       value = "0,67.29,30"; 
      } 
     ); 
    }, 
     { 
     body =   { 
      "error_code" = 3; 
      "error_msg" = "Unknown method"; 
      "request_args" =    (
           { 
        key = sdk; 
        value = ios; 
       }, 
           { 
        key = "migration_bundle"; 
        value = "fbsdk:20131015"; 
       }, 
           { 
        key = format; 
        value = json; 
       }, 
           { 
        key = "access_token"; 
        value = ACCESS_TOKEN_REMOVED; 
       }, 
           { 
        key = "_fb_url"; 
        value = "method/auth.extendSSOAccessToken"; 
       }, 
           { 
        key = "_fb_profilable_request_id"; 
        value = 1747586569; 
       }, 
           { 
        key = method; 
        value = "auth_extendssoaccesstoken"; 
       }, 
           { 
        key = "_fb_batch_child_request"; 
        value = 1; 
       }, 
           { 
        key = "_fb_batch_expires"; 
        value = 1387787339; 
       }, 
           { 
        key = "_fb_batch_sig"; 
        value = AfiDnh1EPSHTbQKV; 
       } 
      ); 
     }; 
     code = 200; 
     headers =   (
         { 
       name = "Access-Control-Allow-Origin"; 
       value = "*"; 
      }, 
         { 
       name = "Cache-Control"; 
       value = "private, no-cache, no-store, must-revalidate"; 
      }, 
         { 
       name = Connection; 
       value = close; 
      }, 
         { 
       name = "Content-Type"; 
       value = "application/json"; 
      }, 
         { 
       name = Expires; 
       value = "Sat, 01 Jan 2000 00:00:00 GMT"; 
      }, 
         { 
       name = Pragma; 
       value = "no-cache"; 
      }, 
         { 
       name = "x-fb-loadmon"; 
       value = "0,67.29,30"; 
      } 
     ); 
    } 
) 

2013-12-23 09:29:48.899 RunGuru[1559:60b] FBSDKLog: Request <#1115>: 
    URL: https://graph.facebook.com/1409052495999988?fields=supports_attribution,supports_implicit_sdk_logging,suppress_native_ios_gdp,name&format=json&migration_bundle=fbsdk%3A20131015&sdk=ios 
    Method: GET 
    UserAgent: FBiOSSDK.3.10.0 
    MIME: multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f 

2013-12-23 09:29:49.183 RunGuru[1559:60b] FBSDKLog: Response <#1115> 
Duration: 283 msec 
Size: 138 kB 
Response Body: 
(
     { 
     body =   { 
      id = 1409052495999988; 
      name = RunGuru; 
      "supports_attribution" = 1; 
      "supports_implicit_sdk_logging" = 1; 
      "suppress_native_ios_gdp" = 1; 
     }; 
     code = 200; 
    } 
) 

2013-12-23 09:29:49.207 RunGuru[1559:60b] FBSDKLog: Request <#1119>: 
    URL: https://graph.facebook.com/1409052495999988/activities?advertiser_tracking_enabled=1&url_schemes=%5B%22fb1409052495999988%22%5D&bundle_version=0.2&bundle_short_version=0.2&event=CUSTOM_APP_EVENTS&migration_bundle=fbsdk%3A20131015&sdk=ios&application_tracking_enabled=1&access_token=ACCESS_TOKEN_REMOVED&bundle_id=pl.runguru.ios.app&advertiser_id=A3D3020D-C158-4485-A2E3-E886FC4FA54D&format=json 
    Method: POST 
    UserAgent: FBiOSSDK.3.10.0 
    MIME: multipart/form-data; boundary=3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f 
    Body Size: 0 kB 
    Attachments: 
    advertiser_tracking_enabled: 1 
    url_schemes: ["fb1409052495999988"] 
    bundle_version: 0.2 
    bundle_short_version: 0.2 
    event: CUSTOM_APP_EVENTS 
    migration_bundle: fbsdk:20131015 
    sdk: ios 
    application_tracking_enabled: 1 
    access_token: ACCESS_TOKEN_REMOVED 
    bundle_id: pl.runguru.ios.app 
    advertiser_id: A3D3020D-C158-4485-A2E3-E886FC4FA54D 
    format: json 
    custom_events_file: <Data - 0 kB> 

2013-12-23 09:29:49.421 RunGuru[1559:60b] FBSDKLog: Response <#1119> 
Duration: 213 msec 
Size: 4 kB 
Response Body: 
(
     { 
     body =   { 
      "FACEBOOK_NON_JSON_RESULT" = true; 
     }; 
     code = 200; 
    } 
) 

回答

1

示例代碼工作正常,奇怪的是,該活動不會出現在出於某種原因沒有時間表飼料。如果您首先查看封面照片附近的個人資料 - >活動日誌按鈕,即可查看您的應用的活動日誌,則會看到它已創建。

確認這個工作最好的方法是使用下面的代碼來安慰了所有Facebook事件:

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

下一次你運行你的代碼,你會看到被送來的實際HTTP請求,並返回響應從臉書應該包含圖形對象的新ID。

+0

它給了我很多反饋。不幸的是,它對我來說沒有任何意義:/ –

+0

你可以分享輸出嗎? –

+0

找不到您正在談論的此活動日誌。你能否更具體一些? –

相關問題