EmbedlyWithBlocks 0.1.1

EmbedlyWithBlocks 0.1.1

测试已测试
语言语言 Obj-CObjective C
许可协议 MIT
发布最后发布2016年11月

Adam Smith 维护。



  • 作者:
  • Adam Smith

EmbedlyWithBlocks 是一个用于 http://embed.ly 的 API 系列的 Objective-C 库(目前支持 Embed 和 Extract API)。Embed.ly有官方的 iOS 库 https://github.com/embedly/embedly-ios,EmbedlyWithBlocks 可以作为替代品使用。

EmbedlyWithBlocks 在以下方面优于官方库:

  • 使用 blocks 代替 delegates。
  • 查询返回完全填充的对象,而不是字典。
  • 可以使用在头文件中声明的常量字符串指定所有可用的服务方法选项。

安装

将 EmbedlyWithBlocks 文件夹拖到您的项目中。在您的 app 委托的 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 方法中添加以下代码:[EmbedlyClient sharedClient].APIKey = @"YOURAPIKEY";

用法

在您想要使用该库的文件中,进行 #import "EmbedlyClient.h"。

要使用一个 URL 查询 Extract API

如果您想传递任何可选的查询参数,请使用在 EmbedlyExtract.h 文件中找到的强类型键创建一个 NSDictionary。例如:

然后,调用 - (void)fetchExtractForURL:(NSString *)requestedURL attributes:(NSDictionary *)attributes completion:(EmbedlyClientFetchExtractCompletionHandler)completion;,传入 Embed.ly 要发送的 URL。

 [[EmbedlyClient sharedClient] fetchExtractForURL:@"http://www.vice.com/read/an-afternoon-inside-the-worlds-only-bunny-museum"
                                             attributes:attributes
                                             completion:^(EmbedlyExtract *extract, NSError *error) {
                                              NSLog(@"%@", extract);
                                          }];

查看 EmbedlyExtract.h 和 EmbedlyEmbed.h 文件,了解所有可以返回的属性。

库中返回的所有错误都是从 Embed.ly 的错误代码映射的 http://embed.ly/docs/api/extract/endpoints/1/extract#error-codes

查看示例项目以了解库的简单用法。

如果您有任何问题,请在此处打开一个 Issue,或者在 Twitter @adamontherun 上联系我。

待办事项

  • 添加对 Display API 的支持
  • 作为 CocoaPod 发布