Google URL Shortener API をPHPで利用するサンプル。このブログのURL「http://blog.fkoji.com/」を短縮してみました。この例ではcURLを使っています。 <?php $url = 'https://www.googleapis.com/urlshortener/v1/url?key=[APIキー]'; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-type: application/json')); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, '{"longU
![Googleの短縮URL「goo.gl」のAPIをPHPのcURLで使うサンプル - F.Ko-Jiの「一秒後は未来」](https://cdn-ak-scissors.b.st-hatena.com/image/square/49bc6ff267b075ca4e583d1b7a0fc5db18dae524/height=288;version=1;width=512/http%3A%2F%2Fblog.fkoji.com%2Fwp-content%2Fuploads%2F2017%2F01%2Ffkoji-twitter-icon.png)