缩短goo.gl公司

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了缩短goo.gl公司相关的知识,希望对你有一定的参考价值。

I needed a simple function to shorten a link with goo.gl and wrote this, thought it may help someone. Note: you still need an API key from goo.gl
  1. function getgoogl($glurl, $apikey) {
  2.  
  3. $userurl = rawurlencode($glurl);
  4.  
  5. $ch = curl_init('https://www.googleapis.com/urlshortener/v1/url?key='.$apikey);
  6. CURLOPT_POST => TRUE,
  7. CURLOPT_RETURNTRANSFER => TRUE,
  8. CURLOPT_HTTPHEADER => array('Content-type: application/json'),
  9. CURLOPT_POSTFIELDS => json_encode(array('longUrl' => $userurl))
  10. ));
  11. $chresults = json_decode(curl_exec($ch));
  12. curl_close($ch);
  13.  
  14. return $chresults->id;
  15. }

以上是关于缩短goo.gl公司的主要内容,如果未能解决你的问题,请参考以下文章

goo.gl公司使用API和API密钥缩短URL-v2

sh Bash:goo.gl#使用Google URL Shortener服务(http://goo.gl)缩短网址。

PHP 缩短goo.gl

sh Bash函数在stdin上使用goo.gl URL缩短器。参见<https://developers.google.com/url-shortener/v1/getting_started

iOS 通用链接和 URL 缩短器

网址缩短网站如何工作?