新しくなったdel.icio.usのAPI仕様と投稿サンプルプログラム
2006年08月21日-
スポンサード リンク
All del.icio.us APIs are done over https and require HTTP-Auth.
8/9 にdel.icio.usのAPIがHTTPSベースのセキュアなものにリニューアルされました(参考)。
これに伴い、これまでのHTTPベースの普通のAPIは使えなくなってしまいました。
ということで、新しい仕様のAPIでブックマークの登録を行うPHPサンプルを次に示します。
(EUCで保存してください)
<?php
function postBookmark($account,$password,$title,$url,$comment,$tag="") {
$title = mb_convert_encoding($title, "UTF-8", "eucjp-win");
$comment = mb_convert_encoding($comment, "UTF-8", "eucjp-win");
$tag = mb_convert_encoding($tag, "UTF-8", "eucjp-win");
$url = urlencode($url);
$title = urlencode($title);
$comment = urlencode($comment);
$tag = urlencode($tag);
$cmd = "curl --silent --user $account:$password -o "response.xml" ".
"-O "https://api.del.icio.us/v1/posts/add?url=$url&description=$title&extended=$comment&tags=$tag&"";
system($cmd);
}
?>
関数として定義してあるので上記ファイルをファイルに保存して次のように呼び出してください。
呼び出すことでブックマーク登録することが可能です。
postBookmark(del.icio.usアカウントID, del.icio.usアカウントPASS, タイトル, URL, コメント, タグ);
※「タグ」はカンマ区切りで複数指定可能です。
del.icio.usの公式APIリファレンスに記載されている他のエンドポイントに関しても、上記関数内の$cmd変数に入っているURLと引数を書き換えることで同じように使えます。
https://api.del.icio.us/v1/posts/get?
https://api.del.icio.us/v1/posts/recent?
https://api.del.icio.us/v1/posts/all?
https://api.del.icio.us/v1/posts/dates?
https://api.del.icio.us/v1/posts/delete?
尚、実行にはcurlコマンドがマシンにインストールされている必要があります。
PHPにはcurlエクステンションも公開されているので、そちらで書いてもよいですね。
参考
Yahoo! API News: del.icio.us and Answers (by Jeremy Zawodny)
スポンサード リンク
Advertisements
SITE PROFILE
最新のブログ記事(新着順)
- CSSやTailwindでのCSSスニペットライブラリ「CSS Snippets Library」
- AIを使ってサイトマップが作れる「Octopus.do」
- ライブラリ依存のないモーダルオープンライブラリ「Blendy」
- 個性的な明朝フリーフォント「築豊初号明朝OFL」
- CSSで太陽が差し込むようなアニメーション実装
- 可愛くアニメーションする「beautifully crafted animated icons」
- アイソメトリックなアイコンがアイコンがPNG,SVGでゲットできる「Isoicons」
- ユニークなカタカナフォントtorisippo
- 美しいメッシュグラデーションをCSSで簡単に取得できる「MSHR」
- TailwindCSSなサイトで使える100以上のアニメーションエフェクト「animata」
- 過去のエントリ