変更する箇所
includes/classes/breadcrumb.php の60行目付近
[php]
} else {
$trail_string .= $this->_trail[$i]['title'];
}
[/php]
上記のコードを以下に変更します。
[php]
} else {
if ($this->…
twitterに関連したwebサービスを作っているとURL短縮の必要が出てくることが多々あります。
そんな時には、有名なurl短縮サービスを利用することになると思うのですが、代表的なbit.ly、TinyURLを利用する方法です。
bit.ly
bit.lyのURL短縮APIを使うには、アカウント登録して、APIキーを取得剃る必要があります。 アカウント登録はここ$long_url = "http://your-long-url";
$req = "http://api.bit.ly/shorten?login=yourAcountName&apiKey=yourApiKey&version=2.0.1&longUrl=".$posted_url;
$contents = file_get_contents($req);
if(isset($contents)) {
$url = json_decode($contents, true);
}
$shorten_url = $url['results'][$posted_url]['shortUrl'];
TinyURL
TinyURLの場合は、アカウント登録なしに利用できる?みたいです。function getTinyUrl($url) {
return file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
}
$long_url = "http://your-long-url";
$shorten_url = getTinyUrl($long_url);
graffiti on the web
この投稿へのコメント
コメントはまだありません。