Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bitlyによる短縮URL作成例(2010/04/11現在)
<?php
$strURLfull = '[[短縮URLにしたいURLを指定してください]]';
$strBitlyResultArr = file("http://api.bit.ly/shorten?version=2.0.1&amp;longUrl=".urlencode($strURLfull)."&amp;login=[[ログインID]]&amp;apiKey=[[api key]]");
$strBitlyResult = "";
foreach($strBitlyResultArr as $strI) {
if(strpos($strI, "shortCNAMEUrl") > 0) {
$strBitlyResultArr = sscanf(trim($strI),'"shortCNAMEUrl": "%s",');
if(strlen($strBitlyResultArr) > 0) {
$strBitlyResult = str_replace('",','',$strBitlyResultArr[0]);
break;
}
}
}
if(strlen($strBitlyResult) == 0) { $strBitlyResult = $strURLfull; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.