{"id":10212,"date":"2013-12-20T18:42:37","date_gmt":"2013-12-20T17:42:37","guid":{"rendered":"http:\/\/flaven.fr\/?p=10212"},"modified":"2013-12-20T18:42:37","modified_gmt":"2013-12-20T17:42:37","slug":"shortener-bit-ly-api-raccourcir-des-urls-a-laide-des-url-shortener-apis","status":"publish","type":"post","link":"https:\/\/flaven.fr\/2013\/12\/shortener-bit-ly-api-raccourcir-des-urls-a-laide-des-url-shortener-apis\/","title":{"rendered":"Shortener, Bit.ly, API &#8211; Raccourcir des URLs \u00e0 l&#8217;aide des URL-Shortener APIs"},"content":{"rendered":"\n<p><!--  Shortener, Bit.ly, API - Raccourcir des URLs \u00e0 l'aide des URL-Shortener APIs   --><br \/>\n\t<!--  Shortener, Bit.ly, API, API, OAuth, PHP, connexion, Google URL Shortener, Bim.im, BioWeb.me, Bit.ly, Bitl.in, Bitlan, br.st, Broken, BudURL, BudURL.Pro, Celly, Cleanify, Crum.bs, DFT.BA, Din.gy, DirectLink, Fanggle, ftw.gd, GatorURL, Go.USA.gov, Google, Href.hu, hu.ly, Ity.im, JumboTweet, L9, Linkbee.com, Linkee, LinksPreadeR, Metamark, Mgnet.me, MiniStash, mtny.mobi, nd, O-Maniac!, Proofeditors.com, Qoiob, qr.cx, Readability, ReLink, Remy, Rewd.co, Safe.mn, Sapo, Short, shortr, Shorty, Shr.Im, Shrten, Snipr, Su.pr, t0.tv, Tiny-URL, Tiny.cc, TinyArro.ws, to.ly, Ttb.li, TwitDoc, UCLA.in, Umini.me, Unshort.me, Untiny, UrlAl, Urloid, X.nu, Xa.ly, Yi.tl --><\/p>\n<p>La c\u00e9l\u00e9rit\u00e9 et la concision sont les deux contraintes \u00e0 respecter afin d&#8217;exister sur les r\u00e9seaux sociaux. Il faut \u00eatre bref et incisif donc il est n\u00e9cessaire de &#8220;d\u00e9couenner&#8221; vos propos de tout le superflu. C&#8217;est donc la raison d&#8217;\u00eatre principale des &#8220;raccourcisseurs&#8221; ou &#8220;shorteners&#8221; d&#8217;URL afin de ne pas vous encombrer des caract\u00e8res si judicieusement choisis pour le SEO.   <\/p>\n<p><i>Une pratique beaucoup moins complexe et sanguinaire que le raccourcissement des t\u00eates (Tsantzas) selon des techniques Jivaros (Shuars).<\/i><\/p>\n<h4>Raccourcir une URL avec l&#8217;API de <code>Bit.ly<\/code><\/h4>\n<p>Pour b\u00e9n\u00e9ficier de l&#8217;API, il faut bien \u00e9videment s&#8217;inscrire sur le service de bit.ly afin de pouvoir d\u00e9clarer une application aupr\u00e8s de l&#8217;API bit.ly.<br \/>\nVous obtenez alors les \u00e9l\u00e9ments essentiels qui vous permettront de tirer profit de l&#8217;API. <\/p>\n<pre lang=\"php\">\r\n  \/* VALUES *\/\r\n  define ('_BITLY_URL_','https:\/\/flaven.fr'); \/\/ L'adresse \u00e0 raccourcir\r\n  define ('_BITLY_LOGIN_','mon_login_bitly'); \/\/ Votre login sur bit.ly\r\n  define ('_BITLY_APIKEY_','R_eb9ded6eab70df20dd949c62099295a6'); \/\/ Votre bitly API Key\r\n  define ('_BITLY_FORMAT_','json'); \/\/ default txt, xml, json \r\n  define ('_BITLY_VERSION_','3');\r\n<\/pre>\n<p><b>Une fois votre application d\u00e9clar\u00e9 aupr\u00e8s de bit.ly<\/b><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2013\/12\/using_bit_ly_api_1.jpg\" alt=\"Shortener, Bit.ly, API - Raccourcir des URLs \u00e0 l'aide des URL-Shortener APIs\" width=\"500\" height=\"313\" \/><\/p>\n<p><b>La console mis \u00e0 disposition de bit.ly<\/b><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" src=\"https:\/\/flaven.fr\/wp-content\/uploads\/2013\/12\/using_bit_ly_api_2.jpg\" alt=\"Shortener, Bit.ly, API - Raccourcir des URLs \u00e0 l'aide des URL-Shortener APIs\" width=\"500\" height=\"313\" \/><\/p>\n<p><b>Le code php pour requ\u00eater l&#8217;API <code>bit.ly<\/code><\/b><\/p>\n<pre lang=\"php\">\r\n  \/* returns the shortened url *\/\r\n  function mon_url_en_short($url,$login,$appkey,$format='json') {\r\n  \t$connectURL = 'http:\/\/api.bit.ly\/v3\/shorten?login='.$login.'&apiKey='.$appkey.'&uri='.urlencode($url).'&format='.$format;\r\n  \treturn curl_get_result_from_bit_ly($connectURL);\r\n  }\r\n\r\n  \/* returns a result form url *\/\r\n  function curl_get_result_from_bit_ly ($url) {\r\n  \t$ch = curl_init();\r\n  \t$timeout = 5;\r\n  \tcurl_setopt($ch,CURLOPT_URL,$url);\r\n  \tcurl_setopt($ch,CURLOPT_RETURNTRANSFER,1);\r\n  \tcurl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);\r\n  \t$data = curl_exec($ch);\r\n  \tcurl_close($ch);\r\n  \treturn $data;\r\n  }\r\n\r\n  \/* VALUES *\/\r\n  define ('_BITLY_URL_','https:\/\/flaven.fr'); \/\/ L'adresse \u00e0 raccourcir\r\n  define ('_BITLY_LOGIN_','mon_login_bitly'); \/\/ Votre login sur bit.ly\r\n  define ('_BITLY_APIKEY_','R_eb9ded6eab70df20dd949c62099295a6');  \/\/ Votre bitly API Key\r\n  define ('_BITLY_FORMAT_','json'); \/\/ default txt, xml, json \r\n  define ('_BITLY_VERSION_','3');\r\n\r\n  \/* get the short url *\/\r\n  $call_to_bit_ly = mon_url_en_short(_BITLY_URL_, _BITLY_LOGIN_, _BITLY_APIKEY_, _BITLY_FORMAT_);\r\n\r\n    $obj = json_decode($call_to_bit_ly);\r\n    \/* for debug *\/\r\n  \t\/\/ var_dump($obj);\r\n\r\n    \/* output *\/\r\n    $short_url = $obj->{'data'}->{'url'};\r\n    echo 'The short URL is:  '.$short_url;\r\n\r\n    echo ('<br>');\r\n\r\n    $long_url = $obj->{'data'}->{'long_url'};\r\n    echo 'The long URL is:  '.$long_url;\r\n  \r\n<\/pre>\n<p><b>Ce qui produira le r\u00e9sultat suivant.<\/b><\/p>\n<blockquote><p>\nThe short URL is: http:\/\/bit.ly\/1fJafzY<br \/>\nThe long URL is: https:\/\/flaven.fr\/\n<\/p><\/blockquote>\n<p><b>Conclusion : Il existe pl\u00e9thore de &#8220;shorteners&#8221; notamment google offre aussi une API tout aussi avanc\u00e9e. C&#8217;est vrai que bit.ly a une sorte d&#8217;ant\u00e9riorit\u00e9 dans la pratique du raccourci, sa documentation et les librairies existantes pour se connecter sont assez nombreuses. Un choix naturel donc.<\/b><\/p>\n<h2>En savoir plus<\/h2>\n<ul>\n<li>The David Walsh Blog<br \/><a href=\"http:\/\/davidwalsh.name\/\" target=\"_blank\">http:\/\/davidwalsh.name\/<\/a><\/li>\n<li>Create Bit.ly Short URLs Using PHP: API Version 3<br \/><a href=\"http:\/\/davidwalsh.name\/bitly-api-php\" target=\"_blank\">http:\/\/davidwalsh.name\/bitly-api-php<\/a><\/li>\n<li>bitly API Documentation<br \/><a href=\"http:\/\/dev.bitly.com\/\" target=\"_blank\">http:\/\/dev.bitly.com\/<\/a><\/li>\n<li>Raccourcir une url avec l\u2019api de bit.ly en php<br \/><a href=\"http:\/\/emilegirard.com\/dev\/php\/raccourcir-url-api-bitly-php.html\" target=\"_blank\">http:\/\/emilegirard.com\/dev\/php\/raccourcir-url-api-bitly-php.html<\/a><\/li>\n<li>How do I find my API key?<br \/><a href=\"http:\/\/support.bitly.com\/knowledgebase\/articles\/76785-how-do-i-find-my-api-key-\" target=\"_blank\">http:\/\/support.bitly.com\/knowledgebase\/articles\/76785-how-do-i-find-my-api-key-<\/a><\/li>\n<li>71 URL-Shortener APIs: Bit.ly, Google URL Shortener and Tiny-URL Open<br \/><a href=\"http:\/\/blog.programmableweb.com\/2012\/10\/31\/71-url-shortener-apis-bit-ly-google-url-shortener-and-tiny-url-open\/\" target=\"_blank\">http:\/\/blog.programmableweb.com\/2012\/10\/31\/71-url-shortener-apis-bit-ly-google-url-shortener-and-tiny-url-open\/<\/a><\/li>\n<li>Google URL Shortener API<br \/><a href=\"https:\/\/developers.google.com\/url-shortener\/v1\/getting_started?hl=fr-FR\" target=\"_blank\">https:\/\/developers.google.com\/url-shortener\/v1\/getting_started?hl=fr-FR<\/a><\/li>\n<li>Google URL Shortener gets an API<br \/><a href=\"http:\/\/googlecode.blogspot.fr\/2011\/01\/google-url-shortener-gets-api.html\" target=\"_blank\">http:\/\/googlecode.blogspot.fr\/2011\/01\/google-url-shortener-gets-api.html<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>La c\u00e9l\u00e9rit\u00e9 et la concision sont les deux contraintes \u00e0 respecter afin d&#8217;exister sur les r\u00e9seaux sociaux. Il faut \u00eatre bref et incisif donc il&hellip; <\/p>\n<p class=\"text-center\"><a href=\"https:\/\/flaven.fr\/2013\/12\/shortener-bit-ly-api-raccourcir-des-urls-a-laide-des-url-shortener-apis\/\" class=\"more-link\">Continue reading &rarr; <span class=\"screen-reader-text\">Shortener, Bit.ly, API &#8211; Raccourcir des URLs \u00e0 l&#8217;aide des URL-Shortener APIs<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":10216,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"bf_ai_meta_description":"Raccourcir des URLs avec Bit.ly API optimise la gestion des r\u00e9seaux sociaux. Utilisez des outils sp\u00e9cifiques pour des r\u00e9sultats pr\u00e9cis.","bf_ai_og_title":"Raccourcir des URLs avec Bit.ly API","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[3439,3444,3446,3447,3450,3435,3452],"tags":[2183,1992,1993,1990,1994,1995,1996,1997,1998,1999,2000,2001,1939,2005,2006,2007,2008,2009,2214,1991,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,1895,20,2024,2025,2026,2027,2028,2029,2030,2031,2032,2033,1989,2034,2035,2036,2037,2038,2039,2040,2041,2042,2043,2044,2045,2046,2047,2048,2049,2050,2051,2052,2053,2054,2055],"class_list":["post-10212","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apis-integration","category-programming-databases","category-social-media-community","category-technology-trends","category-ux-product-design","category-web-development","category-wordpress-cms","tag-api","tag-bim-im","tag-bioweb-me","tag-bit-ly","tag-bitl-in","tag-bitlan","tag-br-st","tag-broken","tag-budurl","tag-budurl-pro","tag-celly","tag-cleanify","tag-connexion","tag-directlink","tag-fanggle","tag-ftw-gd","tag-gatorurl","tag-go-usa-gov","tag-google","tag-google-url-shortener","tag-href-hu","tag-hu-ly","tag-ity-im","tag-jumbotweet","tag-l9","tag-linkbee-com","tag-linkee","tag-linkspreader","tag-metamark","tag-mgnet-me","tag-ministash","tag-mtny-mobi","tag-nd","tag-o-maniac","tag-oauth","tag-php","tag-proofeditors-com","tag-qoiob","tag-qr-cx","tag-readability","tag-relink","tag-remy","tag-rewd-co","tag-safe-mn","tag-sapo","tag-short","tag-shortener","tag-shortr","tag-shorty","tag-shr-im","tag-shrten","tag-snipr","tag-su-pr","tag-t0-tv","tag-tiny-url","tag-tiny-cc","tag-tinyarro-ws","tag-to-ly","tag-ttb-li","tag-twitdoc","tag-ucla-in","tag-umini-me","tag-unshort-me","tag-untiny","tag-urlal","tag-urloid","tag-x-nu","tag-xa-ly","tag-yi-tl"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3Vuhl-2EI","jetpack_featured_media_url":"https:\/\/flaven.fr\/wp-content\/uploads\/2013\/12\/using_bit_ly_api_bf.jpg","_links":{"self":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts\/10212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/comments?post=10212"}],"version-history":[{"count":2,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts\/10212\/revisions"}],"predecessor-version":[{"id":10217,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/posts\/10212\/revisions\/10217"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/media\/10216"}],"wp:attachment":[{"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/media?parent=10212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/categories?post=10212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/flaven.fr\/happy-api\/wp\/v2\/tags?post=10212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}