Tag: @niftyクリップ API PHP

APIの説明ページ

ラッピングしたクラス

使い方

クリップ数の取得

<?php

require_once 'Nifty/Clip.php';

$url = array('http://www.nifty.com/',
             'http://clip.nifty.com/');

try {
    $res = Nifty_Clip::counter($url);
//    $res = Nifty_Clip::counter($url, Nifty_Clip::TARGET_SITE);
    foreach ($res['clips'] as $clip) {
        echo $clip['url'], ' : ', $clip['count'], "\n";
    }
} catch (NiftyClipException $e){
    echo $e->getMessage();
}

クリップ情報の取得

<?php

require_once 'Nifty/Clip.php';

$url = 'http://www.nifty.com/';

try {
    $res = Nifty_Clip::entry($url);
    echo $res['title'], "\n";
    foreach($res['users'] as $user) {
        echo mb_convert_encoding($user['nickname'], 'euc-jp', 'utf-8'), " : ";
        echo mb_convert_encoding($user['comment'], 'euc-jp', 'utf-8'), "\n";
    }
} catch (NiftyClipException $e){
    echo $e->getMessage();
}

クリップの検索

<?php

require_once 'Nifty/Clip.php';

$keyword = 'ゲーム';
$target  = Nifty_Clip::TARGET_TITLE;
$sortkey = Nifty_Clip::SORT_DATE;
$span    = 100;
$start   = 0;
$max     = 5;

try {
    $res = Nifty_Clip::search($keyword, $target, $sortkey, $span, $start, $max);
    foreach ($res['clips'] as $clip) {
        echo mb_convert_encoding($clip['title'], 'euc-jp', 'utf-8'), "\n";
    }
} catch (NiftyClipException $e){
    echo $e->getMessage();
}

添付ファイル: fileNifty_Clip.zip 217件 [詳細]

Last-modified: 2008-09-24 (水) 17:14:12 (3311d)