ニュース/イベント
news > list
ニュース/イベント一覧をリクエストします。
リクエストの構築
リクエストURLとGET変数
リクエスト固有のGET変数
| 変数 | 値 | 説明 |
|---|---|---|
| go | news | APIセクション |
| do | list | APIアクション |
リクエストURLは以下のようになります。必須情報(key, timestamp, salt, signature)を追加することを忘れないでください。
https://....../api.phpgo=news&do=list&{required information}
POST変数
以下のリストフィルターはPOST変数を使って利用できます。フィルターは複数同時に使用可能です。
| 変数 | 値 | 説明 |
|---|---|---|
| fields | (string) "field1,field2,..." | 結果に含めるフィールドを指定します。 "*" = すべてのフィールド(デフォルト) "field1, field2, field3" = フィールドのサブセット(推奨/カンマ区切り) 可能なフィールド: id, id_user, status, status_moderation, type, title, title_url, description, description_seo, tags, img_legend, img_poster, img_social, img_thumbnail, img_icon, date, date_end, views_page, socialize, allow_comments, notification, notification_link_type, notification_link, map, map_center_lat, map_center_lng, map_zoom, map_type, map_marker_lat, map_marker_lng, id_import, date_lastmod |
| ページングオプション | ||
| resultsPerPageFilter | (int) n | 1ページあたりの結果の数(何件表示か) |
| current_page | (int) n | 現在のページ数(何ページ目か) |
| paging | (int) 0|1 | ページングを有効/無効にする |
| limit | (int) n | 結果制限 ※"resultsPerPageFilter"が未設定かつ"paging=0"の場合のみ |
| よく使われるフィルター | ||
| idUserFilter | (int) author ID | 指定したユーザーからのニュース/イベントを一覧表示します。 |
| statusFilter | (mixed) status | 指定したステータスに一致するニュース/イベントを一覧表示します。 利用可能な値:0 (非アクティブ), 1 (アクティブ), "any" 注:ハッシュなしのリクエストではアクティブで承認済のニュース/イベントのみを返します。 |
| sortByFilter | (string) "option" | リストを並べ替えます。 利用可能な値:"date" (デフォルト、日付の新しい順), "title","views_page","id","random","randomSeed","dateRevUp" (今後のイベント/開催日時の近い順), "date2" (日付の古い順) |
| typeFilter | (mixed) type | 指定したタイプのニュース/イベントを一覧表示 利用可能な値:"any", 0 (ニュース), 1 (イベント) |
| tagsFilter | (string) "tag1,tag2,..." | タグに従ってニュース/イベントを一覧表示します(カンマ区切り)。 利用可能な値:"any", "clips", "ads" |
| idFilter | string) "ID1,ID2,..." | IDが指定されたものと一致するニュース/イベントを一覧表示します(カンマ区切り)。 |
| 日付フィルター | ||
| dateStartFilter | (int) timestamp | 日付がタイムスタンプの日付と同じかそれより後であるニュース/イベントを一覧表示します(00:00:00から)。 |
| dateStartMaxFilter | (int) timestamp | 日付がタイムスタンプの日付と同じかそれより前であるニュース/イベントを一覧表示します(00:00:00から)。 |
| dateEndFilter | (int) timestamp | 「終了日」の日付がタイムスタンプの日付と同じかそれより前であるニュース/イベントを一覧表示します(23:59:59まで)。 |
| カテゴリーフィルター | ||
| categoriesFilter | (int) n | カテゴリーに含まれるニュース/イベントを一覧表示します。 カテゴリーIDを指定するか、カテゴリーに関連付けられていないニュース/イベントに"-1"を指定します。 |
| categoriesFilterStrict | (int) 0|1 | "categoriesFilter"により指定されたカテゴリーに直接関連付けられたニュース/イベントを一覧表示します。 カテゴリーの継承は無視されます。 |
| 検索フィルター | ||
| search | (string) "term" | 検索する用語 |
| searchMode | (string) "mode" | システムが用語を検索する方法 利用可能な値: 標準モード(高速):完全に一致するものを探します。 "std1" = タイトル+タグで検索 "std2" = タイトル+タグ+短い説明で検索 "std3" (デフォルト) = タイトル検索+タグ+詳細説明で検索 単語モード(低速、より多く一致):用語を単語に分割し、それらの可能な組み合わせ全てを探して検索します。 "words1" = タイトル+タグで検索 "words2" = タイトル+タグ+短い説明で検索 "words3" = タイトル検索+タグ+詳細説明で検索 |
応答例
リクエストが成功した場合は、以下の内容のレスポンスを受け取ります。
・list_total_found:(ページングの目的で)基準に一致した、見つかったアイテムの合計数。
・list_total:返されたリストの項目数。これは通常"limit"もしくは"resultsPerPageFilter"の値と一致します。
・list:アイテムリスト
{
"list_total_found": "38",
"list_total": 5,
"list": [{
"datesorthint": "1427355660",
"id": "58",
"img_poster": "http:\/\/...\/public\/common\/images\/_default_event_poster.gif",
"title": "Company celebration",
"type": "1",
"type_name": "event",
"user_alias": "InterStream"
}, {
"datesorthint": "1421622000",
"id": "33",
"img_poster": "http:\/\/...\/uploads\/images\/event_33_1405010853_poster.jpg",
"title": "Live webcast",
"type": "1",
"type_name": "event",
"user_alias": "InterStream"
}, {
"datesorthint": "1420109160",
"id": "57",
"img_poster": "http:\/\/...\/public\/common\/images\/_default_event_poster.gif",
"title": "Anual meeting",
"type": "1",
"type_name": "event",
"user_alias": "InterStream"
}, {
"datesorthint": "1420022700",
"id": "56",
"img_poster": "http:\/\/...\/public\/common\/images\/_default_event_poster.gif",
"title": "Eastern party",
"type": "1",
"type_name": "event",
"user_alias": "InterStream"
}, {
"datesorthint": "1419158700",
"id": "55",
"img_poster": "http:\/\/...\/public\/common\/images\/_default_event_poster.gif",
"title": "Halloween party",
"type": "1",
"type_name": "event",
"user_alias": "InterStream"
}]
}
認証情報にGETの許可がない場合など、リクエストが失敗した場合のレスポンス
{
"error" : "REQUEST_ERROR",
"error_long" : "Permission error: GET"
}
このリクエストは以下のエラーを返す可能性があります。
・REQUEST_ERROR | No News/Events were found
ニュース/_イベントが見つかりません。
その他のエラー内容に関しては一般的なエラーメッセージを確認してください。
PHPサンプルコード
GETおよびPOSTデータを準備します。
// GET変数
$GET_VARS = array(
"go" => "news",
"do" => "list"
);
// POST変数
$POST_VARS = array(
"fields" => "id,title,img_poster", // ID,タイトル,ポスター画像の各フィールド
"paging" => 1, // ページング有効
"resultsPerPageFilter" => 5, // 1ページにつき5件表示
"current_page" => 1, // 1ページ目に戻る
"sortByFilter" => "date", // 日付で並べ替え
"typeFilter" => 1, // イベントのみ一覧表示
"statusFilter" => "any" // 全てのステータスを表示
);
salt, timestamp, signatureを生成してリクエストを送信します。
以下のコードブロックはすべてのハッシュつきリクエストに共通です。
// APIベースURLと認証情報の収集
$API_URL = "https://www.interstreamdomain.tv/api.php";
$API_KEY_ID = "1b323a1cb879fd4e66530fbad07a32ee";
$API_SHARED_SECRET = "MWIzMjNhMWNiODc5ZmQ0ZTY2NTMwZmJhZDA3YTMyZWViOTQ3MDJiOGM2ZTU2NjE3"; // 公開しないでください
// salt, timestamp, signatureの生成
$salt = md5(mt_rand());
$timestamp = time();
$signature = base64_encode(hash_hmac('sha256', $salt.$timestamp, $API_SHARED_SECRET, true));
// key, salt, timestamp, signatureをGET変数に追加
$GET_VARS["timestamp"] = $timestamp; // UTCタイムスタンプ
$GET_VARS["salt"] = $salt;
$GET_VARS["key"] = $API_KEY_ID ; // APIキーID:これは公開されており、アプリケーションを識別するためにAPIによって使用されます
$GET_VARS["signature"] = $signature;
// リクエストURLを作成します。HTTPクエリを作成するためにPHPの組み込み関数を使用しない場合は、値をURLエンコードすることを忘れないでください。
$REQUEST_URL = $API_URL."?".http_build_query($GET_VARS);
// ".../api.php?go=api_subject&do=api_action&etc..."のようにURLを構築
// 新しいcURLリソースを作成して適切なオプションを設定
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $REQUEST_URL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $POST_VARS);
// PHPホストに有効なSSL証明書がない場合は、SSL証明書の検証を無効にする必要があります。これは危険であり、有効な証明書がインストールされるまで一時的に行われるべきです。
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Turns off verification of the SSL certificate.
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Turns off verification of the SSL certificate.
// APIにリクエストを送信
$response = curl_exec($ch);
// レスポンス処理
if (!$response) {
echo 'API call failed';
}
else
{
print_r(json_decode($response,true));
}