php 谷歌짧은주소만들기
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 谷歌짧은주소만들기相关的知识,希望对你有一定的参考价值。
// goo.gl 짧은주소 만들기
function googl_short_url($longUrl)
{
global $config;
// Get API key from : http://code.google.com/apis/console/
// URL Shortener API ON
$apiKey = $config['cf_googl_shorturl_apikey'];
$postData = array('longUrl' => $longUrl);
$jsonData = json_encode($postData);
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url?key='.$apiKey);
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
curl_setopt($curlObj, CURLOPT_POST, 1);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);
$response = curl_exec($curlObj);
//change the response json string to object
$json = json_decode($response);
curl_close($curlObj);
return $json->id;
}
以上是关于php 谷歌짧은주소만들기的主要内容,如果未能解决你的问题,请参考以下文章
javascript 3자로DIGIT숫자로만들기(Javascript)
powershell howto - 깃개인깃이그노어파일만들기
markdown 맥에서라즈베리파이용.Net Core앱만들기
javascript React hooks - useRef로변수사용하기(값은변경되지만화면에영향끼치지않음)
鶴山 李正浩 博士(探訪墓所)
javascript 고도몰이나기타솔루션사에서모바일주문내기더보기버튼눌렀을때리뷰작성버튼에링크붙여주는스크립트