Exemplo n.º 1
0
 /**
  * Test tweetsList()
  *
  * @return void
  */
 public function testTwList()
 {
     $this->assertInstanceOf(PDOStatement::class, $this->SaveTweet->tweetsList());
 }
Exemplo n.º 2
0
try {
    $conf = config("twitter");
    $TwistOAuth = new TwistOAuth($conf["ck"], $conf["cs"], $conf["ot"], $conf["os"]);
    $SaveTweet = new SaveTweet(config("db"), $TwistOAuth);
    $Cache = new Cache($TwistOAuth);
    $filter = [];
    $user = filter_input(INPUT_GET, "user");
    if (!empty($user) && is_string($user)) {
        foreach (explode(",", $user) as $sn) {
            $filter[] = $sn;
        }
    }
    $user_ids = [];
    $names = [];
    $create_cache = [];
    foreach ($SaveTweet->tweetsList() as $row) {
        $user_ids[] = $row["user_id"];
    }
    if (count($user_ids) !== 0) {
        $statuses = $TwistOAuth->get("users/lookup", ["user_id" => implode(",", array_values(array_unique($user_ids)))]);
        foreach ($statuses as $status) {
            if ($Cache->exists($status->id_str)) {
                $json = json_decode(file_get_contents(config("cache.path") . "/{$status->id_str}/data.json"));
                $names[$status->id_str]["name"] = $json->name;
                $names[$status->id_str]["screen_name"] = $json->screen_name;
                $names[$status->id_str]["icon"] = $json->icon;
                continue;
            }
            $create_cache[] = $status->id_str;
            $names[$status->id_str] = ["name" => $status->name, "icon" => str_replace("_normal", "", $status->profile_image_url_https)];
        }