Ejemplo n.º 1
0
function download_user_profile_image(&$website, $object)
{
    $image_url = $object->image();
    $website->get_file($image_url);
    $array = \parse_url($image_url, \PHP_URL_PATH);
    save_binary_file($website, '/home/jawaad/test.jpg');
}
Ejemplo n.º 2
0
$data_arr_len = count($data_arr);
for ($count = 0; $count < $data_arr_len; $count++) {
    $message = $data_arr[$count]["message"];
    $object_id = $data_arr[$count]["object_id"];
    $sql = "SELECT COUNT(obj_id) FROM beauty WHERE obj_id = :object_id";
    $stmt = $link->prepare($sql);
    $stmt->execute(array(":object_id" => $object_id));
    if ($stmt->fetchColumn() !== 0) {
        break;
    }
    if (mb_stristr($message, "正妹") === false) {
        continue;
    }
    save_binary_file("https://graph.facebook.com/" . $object_id . "/picture?type=normal");
    upload_photo("temp.jpg", $message);
    save_binary_file("https://graph.facebook.com/" . $object_id . "/picture?type=thumbnail");
    upload_photo("temp.jpg", $message);
    $sql = "INSERT INTO beauty(message,obj_id) VALUES(:message,:obj_id)";
    try {
        $stmt = $link->prepare($sql);
        $stmt->execute(array(":message" => $message, ":obj_id" => $object_id));
    } catch (PDOException $e) {
        //check duplicate entries.
        if ($e->errorInfo[0] == '23000' && $e->errorInfo[1] == '1062') {
            if (file_exists("error_log.log")) {
                @unlink("error_log.log");
            }
            file_put_contents("error_log.log", "Duplicate data\r\n");
        } else {
            file_put_contents("error_log.log", "Other errors.\r\n");
        }