gpt4 book ai didi

facebook - Facebook 目标代码示例。

转载 作者:行者123 更新时间:2023-12-02 08:00:02 26 4
gpt4 key购买 nike

这是我从 Facebook 获得的使用自定义对象的示例代码。我通过自定义操作创建了这个,以利用 Facebook 故事。
Facebook 文档:
https://developers.facebook.com/docs/opengraph/overview/

NSMutableDictionary<FBGraphObject> *object =
[FBGraphObject openGraphObjectForPostWithType:@"sotd_facebook:new_zombie"
title:@"Sample New Zombie"
image:@"https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png"
url:@"http://samples.ogp.me/191078581053171"
description:@""];;

[FBRequestConnection startForPostWithGraphPath:@"me/objects/sotd_facebook:new_zombie"
graphObject:object
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
// handle the result
}];

我很好奇如何在 Facebook IOS sdk 中使用这个对象进行操作。我尝试使用以下代码,但在创建 FBRequestConnection 时崩溃。

[__NSCFBoolean dataUsingEncoding:]: unrecognized selector sent to instance 0x3af00530
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean dataUsingEncoding:]: unrecognized selector sent to instance 0x3af00530'

[编辑]
我创建了 FBOpenGraphObject 并使用 FBRequestConnection 方法 startForPostOpenGraphObject:completionHandler。在完成处理程序中,我从结果中检索 id,并将其放入另一个具有 id 的 FBOpenGraphObject 中。但它仍然崩溃。

NSMutableDictionary<FBOpenGraphObject> *object = [FBGraphObject
openGraphObjectForPostWithType:@"sotd_facebook:new_zombie"
title:@"Sample New Zombie"
image:@"https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png"
url:@"http://samples.ogp.me/191078581053171"
description:@""];



[FBRequestConnection startForPostOpenGraphObject:object
completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
// handle the result
// handle the result
if (error)
{
NSLog(@"Error sharing story: %@", error.localizedDescription);
}
else if(result != nil)
{
NSLog(@"Result: %@", result);
NSString* resultID = [result objectForKey:@"id"];

NSMutableDictionary<FBOpenGraphObject> *newObject = [FBGraphObject openGraphObjectForPost];
newObject.id = resultID;


[FBRequestConnection startForPostWithGraphPath:@"me/objects/sotd_facebook:new_zombie"
graphObject:newObject completionHandler:^(FBRequestConnection *connection,
id result,
NSError *error) {
// handle the result
// handle the result
if (error)
{
NSLog(@"Error sharing story: %@", error.localizedDescription);
}
else
{
NSLog(@"Result: %@", result);
}

}];
}

}];

崩溃日志:

2013-08-16 18:47:11.013 ZombieBlackout[3408:907] -[__NSCFBoolean dataUsingEncoding:]: unrecognized selector sent to instance 0x3a118530 2013-08-16 18:47:11.015 ZombieBlackout[3408:907] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean dataUsingEncoding:]: unrecognized selector sent to instance 0x3a118530'

最佳答案

我也遇到了同样的问题。您首先需要发布对象,然后获取其 ID,并提供对象 ID 而不是对象本身:

NSMutableDictionary<FBOpenGraphObject> *object = [...];
[FBRequestConnection startForPostOpenGraphObject:object completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
if(result != nil){
NSString* resultID = [result objectForKey:@"id"];
[FBRequestConnection startForPostWithGraphPath:@"me/objects/sotd_facebook:new_zombie"
graphObject:resultID //...

该对象首先作为对象发布到 Facebook,然后您可以对该对象使用操作 (new_zombie)。我也处于完全相同的情况(启用了 2013 年 7 月的重大更改),试图弄清楚如何在 Facebook 上一步创建所有内容,但如果不使用单独的自托管网络服务器,则无法弄清楚。在我的问题中,我收到有关对象已发布且无法再次发布的错误。如果您没有遇到此问题,现在可以继续处理此问题。

看来错误本身是由对象字典中的 fbsdk:create_object 键(及其值 1)引起的。该 key 由 Facebook SDK 自动添加到对象中。当我在发布之前显式删除此键时,它不会在发布时引发异常,但我关于发布对象的答案仍然适用。即使您删除该 key ,您也会在服务器端收到一个 OAuthException ,告诉您该对象不是“引用”。不过,如果事实证明我的观点是错误的,我真的很高兴。

关于facebook - Facebook 目标代码示例。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17563582/

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