Пример #1
0
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=utf-8");
date_default_timezone_set("Asia/Tokyo");
$time_start = microtime(true);
include "getMultiCotents.php";
// メンバーのリスト 並び順は http://www.gochiusa.com/contents/chara/index.html に準拠。
$member_list = array("64319102" => array("chara" => "cocoa", "names" => array("心愛", "ココア")), "538308036" => array("chara" => "chino", "names" => array("智乃", "チノ")), "14157941" => array("chara" => "rize", "names" => array("理世", "リゼ")), "873775722" => array("chara" => "chiya", "names" => array("千夜")), "2439755767" => array("chara" => "syaro", "names" => array("紗路", "シャロ")), "2239375134" => array("chara" => "maya", "names" => array("麻耶", "マヤ")), "547406123" => array("chara" => "megumi", "names" => array("恵", "メグ")), "463401611" => array("chara" => "mocha", "names" => array("モカ")));
// 何名居るかをキャッシュする
$member_count = count($member_list);
// URL作成
$currentURL = (empty($_SERVER["HTTPS"]) ? "http" : "https") . "://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
foreach ($member_list as $id => $chara) {
    $member_url_list[] = str_replace("api.php", "", $currentURL) . "user_information.php?id=" . $id;
}
// 一気に取得(すごい早い)
$user_info_list = getMultiContents($member_url_list);
// 配列の頭を数字にして扱いやすく
$user_info_list = array_values($user_info_list);
// ジャッジ
$hopping_count = 0;
// 最終的なメンバー情報を入れるリスト
$member_info_list = array();
foreach ($user_info_list as $user_info) {
    // 正しく読み込まれているか
    if ($user_info["http_code"] !== 200) {
        $result = array("status" => "error", "data" => null, "message" => "ユーザー情報の読み込みに失敗しました。");
        die(json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
    }
    // JSON配列型でデコード
    $member_info = @json_decode($user_info["content"], true);
    // JSONの解釈に成功したか
Пример #2
0
<?php

header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=utf-8");
date_default_timezone_set("Asia/Tokyo");
$time_start = microtime(true);
include "getMultiCotents.php";
// メンバーのリスト 並び順は http://www.gochiusa.com/contents/chara/index.html に準拠。
$member_list = array("64319102", "538308036", "14157941", "873775722", "2439755767", "2239375134", "547406123", "463401611");
$member_count = count($member_list);
// URL作成
foreach ($member_list as $member_id) {
    $member_url_list[] = "http://lab.mizle.net/status.gochiusa/user_information.php?id=" . $member_id;
}
// 一気に取得(すごい早い)
$results = getMultiContents($member_url_list);
// 配列の頭を数字にして扱いやすく
$results = array_values($results);
// 正しく読み込まれているか
for ($count = 0; $count < $member_count; $count++) {
    if ($results[$count]["http_code"] == "0") {
        $result = array("status" => "error", "data" => null, "message" => "ユーザー情報の読み込みに失敗しました。");
        die(json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
    }
}
// JSON配列型でデコード
$member_cocoa = json_decode($results[0]["content"], true);
$member_chino = json_decode($results[1]["content"], true);
$member_rize = json_decode($results[2]["content"], true);
$member_chiya = json_decode($results[3]["content"], true);
$member_syaro = json_decode($results[4]["content"], true);
Пример #3
0
$hash_key = md5($google_xml_url);
if (($ranking = apc_fetch($hash_key)) == false) {
    // urlのリストを作成する
    $xml = simplexml_load_file($google_xml_url);
    foreach ($xml->url as $data) {
        if (is_object($data->loc)) {
            $url = (string) $data->loc;
        } else {
            $url = $data->loc;
        }
        // fqlを作成する
        $fql = 'SELECT url, like_count FROM link_stat WHERE url IN " ' . $url . '"';
        $fql_query_url = "https://api.facebook.com/method/fql.query?format=json&query=" . urlencode($fql);
        $urls[] = $fql_query_url;
    }
    $fql_query_obj = getMultiContents($urls, 20);
    //$fql_query_obj		= json_decode($fql_query_result, true);
    if (empty($fql_query_obj)) {
        die('not found');
    }
    foreach ($fql_query_obj as $key => $row) {
        $like_count[$key] = $row['like_count'];
    }
    array_multisort($like_count, SORT_DESC, $fql_query_obj);
    $ranking = array_slice($fql_query_obj, 0, $limit);
    apc_store($hash_key, $ranking);
}
$string = "<tr>\n";
$string .= "<th>title</th>\n";
$string .= "<th>liked</th>\n";
$string .= "</tr>\n";