Shrtlink - Acortando links desde una API

Si estas haciendo una aplicación medianamente compleja (sobre todo si es para el ámbito social) puede que necesites acortar links cuando un usuario quiere compartir algo. Por suerte, tenemos a disposición ShrtLink, una API que nos permite (enviándole el link a acortar) obtener un link más corto y más amigable para compartir. Para poder utilizarlo, lo único que tenemos que tener es una cuenta en Mashape, que es un gestor de requests a la API. Podemos utilizarlo con muchos lenguajes de programación y cURL. curl -X POST --include 'https://francocorreasosa-shrtlink-v1.p.mashape.com/new' \ -H 'X-Mashape-Key: <tu-apikey-de-mashape>' \ -H 'Content-Type: application/x-www-form-urlencoded' \ -H 'Accept: application/json' \ -d 'link=http://ejemplo-de-link-largo-a-acortar.com/post/geekytheory-link/' Python: # These code snippets use an open-source library. http://unirest.io/python response = unirest.post("https://francocorreasosa-shrtlink-v1.p.mashape.com/new", headers={ "X-Mashape-Key": "<tu-api-key-de-mashape>", "Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json" }, params={ "link": "http://ejemplo-de-link-largo-a-acortar.com/post/geekytheory-link/" } )

¡Hasta desde apps móviles!

// These code snippets use an open-source library. http://unirest.io/objective-c NSDictionary *headers = @{@"X-Mashape-Key": @"<tu-apikey-de-mashape>", @"Content-Type": @"application/x-www-form-urlencoded", @"Accept": @"application/json"}; NSDictionary *parameters = @{@"link": @"http://link-a-acortar.com/post/geekytheory-link"}; UNIUrlConnection *asyncConnection = [[UNIRest post:^(UNISimpleRequest *request) { [request setUrl:@"https://francocorreasosa-shrtlink-v1.p.mashape.com/new"]; [request setHeaders:headers]; [request setParameters:parameters]; }] asJsonAsync:^(UNIHTTPJsonResponse *response, NSError *error) { NSInteger code = response.code; NSDictionary *responseHeaders = response.headers; UNIJsonNode *body = response.body; NSData *rawBody = response.rawBody; }];

Al ejecutar la API, te retorna algo como esto:

{ "id": "12", "shorted_link": "3dj28", "complete_link": "http://geekytheory.com/", "times_visited": 0, "published_by": "Mashape Client", "registration_method": "Mashape" }

A nosotros nos interesa lo que dice "shorted_link": "3dj28",  porque 3dj28 es lo que necesitaremos para armar nuestro link corto. 3dj28 es igual a http://shrtlink.ga/3dj28 y este nos redirige a la web que le hemos pasado. ¡Así de simple!

Para ver la documentación de la API ingresa a el siguiente enlace: https://www.mashape.com/francocorreasosa/shrtlink

保管時にしわがつきやすい素材かどうかは、撮影前の準備にも影響します。採寸後の候補選びでは、スペースエレシュキガル コスプレセットを見ながらサイズ感を比べられます。準備の段階で小物をそろえておくと、当日の見た目を整えやすくなります。