Example #1
0
function RequsetData($gender)
{
    $sql = "SELECT `message`, `obj_id`, `created_time` FROM  `beauty_nttu`  WHERE `message` LIKE '%【" . $gender . "】%'";
    $conn = new ConnectDB();
    $link = $conn->InitialDB();
    $data = $conn->ProcessData($link, $sql, array(), "get-image-id");
    $conn->ConnectClose($link);
    $str = '<h2>資料來源:<a href="https://www.facebook.com/BeautyNTTU/?fref=ts" target="_blank">表特東大</a></h2>
				<p>僅提供瀏覽,欣賞</p>';
    $len = count($data);
    for ($index = 0; $index < $len; $index++) {
        $message = $data[$index]["message"];
        $normal = "https://graph.facebook.com/" . $data[$index]["obj_id"] . "/picture?type=normal";
        $thumbnail = "https://graph.facebook.com/" . $data[$index]["obj_id"] . "/picture?type=thumbnail";
        $str .= '<a title="' . $message . '" class="swipebox" href="' . $normal . '">';
        $str .= '<img src="' . $thumbnail . '" alt="image" class="img-rounded">';
        $str .= '</a>';
    }
    return $str;
}
Example #2
0
        }
        if (isset($page["data"][$CountData]["object_id"])) {
            $ObjectID = $page["data"][$CountData]["object_id"];
        } else {
            $ObjectID = "";
        }
        if (isset($page["data"][$CountData]["created_time"])) {
            $CreatedTime = $page["data"][$CountData]["created_time"];
        } else {
            $CreatedTime = "";
        }
        $data["message"] = str_replace("☺ ", "", trim($message));
        $data["message"] = str_replace("\n", "", $data["message"]);
        $data["object_id"] = $ObjectID;
        $data["created_time"] = $CreatedTime;
        $sql = "INSERT INTO beauty_nttu(message,obj_id,created_time) VALUES(:message,:object_id,:created_time)";
        $result = $connection->ProcessData($conn, $sql, $data, "insert-record");
        switch ($result) {
            case "insert-fail":
                file_put_contents($dir . "script" . "/log/error.log", "insert-fail," . $message . "," . $ObjectID . "\r\n", FILE_APPEND);
                break;
            case "duplicate-entry":
                file_put_contents($dir . "script" . "/log/error.log", "duplicate-entry," . $message . "," . $ObjectID . "\r\n", FILE_APPEND);
                break;
        }
    }
    $response = $client->request('GET', $page["paging"]["next"], ["verify" => false]);
    $page = json_decode($response->getBody(), true);
    $count = count($page["data"]);
}
$connection->ConnectClose($conn);