gpt4 book ai didi

ios - 使用 Facebook iOS SDK 发布运行操作

转载 作者:行者123 更新时间:2023-11-29 12:57:23 91 4
gpt4 key购买 nike

我正在尝试使用来自 Facebook iOS SDK 的图形 API。

到目前为止,我设法使用以下方法发布了简单的状态更新:

[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 与我的不匹配,所以我尝试自己构建类(class),如下所示:

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/";

这会引发错误并提示我的对象缺少类(class)属性。我现在很困惑...

我的应用程序的“运行”操作尚未审核,但我想这不是重点,因为我正在使用我的开发者帐户对其进行测试。

编辑。我从 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;
}
)

最佳答案

您的示例代码运行良好,奇怪的是事件由于某种原因没有出现在时间轴上。如果您首先进入您的个人资料 --> 封面图片附近的事件日志按钮来查看您的应用程序的事件日志,您会看到它已创建。

确认这项工作的最佳方法是使用以下代码控制所有 facebook 事件:

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

下次运行代码时,您将看到实际发送的 HTTP 请求以及从 facebook 返回的响应,其中应包含图形对象的新 ID。

关于ios - 使用 Facebook iOS SDK 发布运行操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20702861/

91 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com