示例#1
0
<?php

$api_key = "cbq1I79DDL8Eec1ctSheVP3psj6YSaPP";
function do_act($target_url, $type, $data, $cookie_file = NULL)
{
    $ch = curl_init();
    if ($type == 'GET') {
        $target_url .= http_build_query($data);
        curl_setopt($ch, CURLOPT_URL, $target_url);
    } else {
        curl_setopt($ch, CURLOPT_URL, $target_url);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
    }
    if (isset($cookie_file)) {
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
    }
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
}
$response = do_act("http://www.plurk.com/API/Realtime/getUserChannel", "POST", array("api_key" => "{$api_key}"), "/tmp/plurk_cookie");
$response = json_decode($response);
$url = $response->comet_server;
$response = do_act("{$url}", "POST", array("api_key" => "{$api_key}"), "/tmp/plurk_cookie");
示例#2
0
文件: autoplurk.php 项目: hoogle/ttt
                                $robot_say = "";
                            }
                        }
                        if (!empty($robot_say)) {
                            $user_id = $poster_arr["user_id"];
                            $plurk_id = $poster_arr["plurk_id"];
                            $post_url = "http://www.plurk.com/API/Profile/getPublicProfile?api_key=" . API_KEY . "&user_id={$user_id}";
                            $pf_arr = json_decode(do_act($post_url, NULL), TRUE);
                            $plurk_nick = $pf_arr["user_info"]["nick_name"];
                            $response_text = "@{$plurk_nick}: {$robot_say}";
                            $post_url = "http://www.plurk.com/API/Responses/responseAdd?api_key=" . API_KEY . "&plurk_id={$plurk_id}&content=" . urlencode($response_text) . "&qualifier=says";
                            do_act($post_url, NULL);
                            echo "({$poster_arr["_cid"]}) ===== [NEW!] ({$t}) ===== " . iconv("utf-8", "big5", trim($poster_arr["user_id"])) . " => " . iconv("utf-8", "big5", trim($poster_arr["content_raw"])) . "\n";
                            echo USERNAME . iconv("utf-8", "big5", " says: {$response_text}\n\n");
                        }
                    }
                } else {
                    $user_arr = $arr["data"][0]["response"]["user_id"];
                    $poster = $arr["data"][0]["user"][$user_arr]["display_name"] . " (" . $arr["data"][0]["user"][$user_arr]["karma"] . ")\n";
                    $post = $arr["data"][0]["response"]["content_raw"] . "\n";
                    echo "({$arr["new_offset"]})" . iconv("utf-8", "big5", trim($poster)) . " => " . iconv("utf-8", "big5", trim($post)) . "\n";
                }
                $new_offset = $arr["new_offset"] + 1;
                $url = $comet_server_uri . $new_offset;
                //echo "offset={$new_offset}\t";
                $arr = json_decode(do_act($url, NULL), TRUE);
            }
        }
        break;
}
echo "\n";
示例#3
0
文件: lib.php 项目: hoogle/ttt
    case "getchannel":
        $nick = $_POST['nick'];
        $pwd = $_POST['pwd'];
        $target_url = "http://www.plurk.com/API/Users/login";
        $data = array("api_key" => API_KEY, "username" => $nick, "password" => $pwd);
        do_act($target_url, $data, $cookie_file);
        $target_url = "http://www.plurk.com/API/Realtime/getUserChannel";
        $data = array("api_key" => API_KEY);
        header("Cache-Control: no-cache");
        header("Content-Type: application/json");
        echo do_act($target_url, $data, $cookie_file);
        break;
    case "getnew":
        $target_url = $_POST['url'];
        header("Cache-Control: no-cache");
        header("Content-Type: application/json");
        echo do_act($target_url, NULL, $cookie_file);
        break;
    case "getplurks":
        $nick = $_POST['nick'];
        $pwd = $_POST['pwd'];
        $target_url = "http://www.plurk.com/API/Users/login";
        $data = array("api_key" => API_KEY, "username" => $nick, "password" => $pwd);
        do_act($target_url, $data, $cookie_file);
        $target_url = "http://www.plurk.com/API/Timeline/getPlurks";
        $data = array("api_key" => API_KEY, "offset" => date("Y-n-dTH:i:s"));
        header("Cache-Control: no-cache");
        header("Content-Type: application/json");
        echo do_act($target_url, $data, $cookie_file);
        break;
}