0

我希望能找到一些帮助来深入了解 Podiokit,即 Podio 的 ObjC-API。我尝试将链接字段的值设置为 URL。我的第一个简单尝试如下所示:

NSDictionary *embedAttributes = [NSDictionary dictionaryWithObject: @"http://www.google.com" forKey: @"url"];            
PKTEmbed *embed = [[PKTEmbed alloc] initWithDictionary: embedAttributes];
item[@"linkfield"] = embed;

我找到了一个使用 PHP 的示例,但没有运气将其转换为 Objective-C:

$attributes = array( 'url' => 'http://www.infranet.com' );
$embed = PodioEmbed::create( $attributes );
$attribute['embed']['embed\_id'] = $embed->embed\_id;
$attribute['file']['file\_id'] = $embed->files[0]->file\_id;
$this->orgItem->field('organizationlink')->set\_value($attribute);

也许有人知道如何做对,会很好:-)

[编辑] PodioKit 手册只是说:

PKTEmbed *link = ...;
item[@"link"] = link;

[编辑 2] 当我尝试保存项目时发生错误。日志说:

Error: Saving file Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: Ungültige Anforderung (400)" UserInfo=0x600000c7ee80 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x6000008358e0> { URL: https://api.podio.com/item/app/_xxxx_/ } { status code: 400, headers {
"Content-Length" = 263;
"Content-Type" = "application/json; charset=utf-8";
Date = "Sat, 27 Sep 2014 19:16:22 GMT";
Server = nginx;
"X-Podio-Request-Id" = yqyl6yku;
"X-Rate-Limit-Limit" = 250;
"X-Rate-Limit-Remaining" = 248;
} }, NSLocalizedDescription=Request failed: Ungültige Anforderung (400), NSErrorFailingURLKey=https://api.podio.com/item/app/_xxxx_/}

谢谢,迈克尔/汉堡

4

1 回答 1

1

Podio的塞巴斯蒂安在这里。您需要先创建 PKTEmbed 对象服务器端,然后将其用作 item 字段的值。所以你会使用:

PKTItem *item = ...;
[[PKTEmbed createEmbedForURLString:@"https://www.google.com"] onSuccess:^(PKTEmbed *embed) {
  item[@"link-field"] = embed;
} onError:^(NSError *error) {
  // Handle error
}];

服务器将为您分配一个 embedID 并为您生成缩略图等。我将考虑添加直接提供 URL 字符串的功能,因为我同意这很有意义。

希望有帮助!

于 2014-10-03T07:00:31.243 回答