Skip to content

mnbayan/embedly-ios

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

embedly-ios

Version Platform

Usage

The Embedly iOS library gives you access to all of Embedly's APIs, but there are two different ways to interact with the APIs:

  • Embed, Extract, and legacy APIs are available through the call{EmbedlyApi,Embed,Extract,...} methods, which initiate an HTTP call which invokes the corresponding delegate method (embedly{Success,Failure}) upon completion.

  • The Display API is different. The build{DisplayUrl,CroppedImageUrl,...} methods simply return an NSString containing the URL for the manipulated image via the Embedly Display API. You can use this URL wherever you would use any other image address (e.g. AFNetworking+UIImage).

The call{EmbedlyApi,Embed,...} methods use delegation to return the result of the API call, so your code will need to implement the EmbedlyDelegate protocol. The API response is returned in 'response', which can be accessed as an NSDictionary.

To make it simpler to cache API calls within your app, the call{EmbedlyApi,Embed,...} functions return a string containing the full Embedly API call. You can use this as a key to store API responses (e.g. in an NSDictionary). This return value is also useful in debugging an API call.

To make batch API calls (multiple URLs at the same time), you can use the callEmbedlyApi:withUrls:params: method, which takes an NSArray of NSStrings. In this case, the API response returned in 'response' can be accessed as an NSArray of NSDictionarys.

Example

A complete example app is available in the Example directory of this repo. Here are some quick examples:

Embedly *e = [[Embedly alloc] initWithKey:@"mykey" delegate:self];
NSString *callUrl = [e callEmbed:@"techcrunch.com/embedly" params:@{@"chars": @"120"} optimizeImages:640];

// within embedlySuccess:withResponse:endpoint:operation:
self.urlTitle.text = [response objectForKey:@"title"];
self.urlProvider.text = [response objectForKey:@"provider_name"];
self.urlDescription.text = [response objectForKey:@"description"];
Embedly *e = [[Embedly alloc] initWithKey:@"mykey" delegate:self];
NSString *resizedImageUrl = [e buildResizedImageUrl:@"http://embed.ly/static/images/office/DSC_0157.JPG" width:250];
NSString *croppedImageUrl = [e buildCroppedImageUrl:@"http://embed.ly/static/images/office/DSC_0123.JPG" width:100 height:100];
NSString *filledImageUrl = [e buildDisplayUrl:@"/1/display/fill" withUrl:@"http://embed.ly/static/images/office/DSC_0161.JPG" params:@{@"width": @"500", @"height": @"500", @"color": @"1bd9f5"}];

Requirements

All of Embedly's products are free to use up to a limit, you just need to sign up for an API key at:

https://app.embed.ly/signup

Make sure to include your API key when you initialize the Embedly object.

If your app is doing well and you need more usage, you can learn more about our plans at:

http://embed.ly/api

Installation

embedly-ios is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "embedly-ios"

To run the example project; clone the repo, and run pod install from the Example directory first. You will need to add your Embedly API key to the initWithKey:delegate: method (replace "mykey" with your API key).

Author

@embedly

License

embedly-ios is available under the MIT license. See the LICENSE file for more info.

About

iOS Library for accessing Embedly API

Resources

License

Stars

Watchers

Forks

Packages

No packages published