Esempio n. 1
0
if (!empty($token) && !empty($users_id2)) {
    $users_id1 = getUsersId($token);
    if (!empty($users_id1)) {
        $sql = "DELETE FROM `follow` WHERE users_id1 = :users_id1 AND users_id2 = :users_id2";
        $stmt = $conn->prepare($sql);
        $stmt->bindParam(':users_id2', $users_id2);
        $stmt->bindParam(':users_id1', $users_id1);
        try {
            $stmt->execute();
        } catch (PDOException $e) {
            echo $e->getMessage();
        }
        $success = "1";
        $msg = "Successfully unfollowed!";
        $result = getAllFollowRequests($users_id1);
        $result1 = getAllFollowers($users_id1);
        $result2 = getAllFollowing($users_id1);
        if (!empty($result)) {
            $data = $result;
        }
        if (!empty($result1)) {
            $followers = $result1;
        }
        if (!empty($result2)) {
            $followings = $result2;
        }
        // $sql1="SELECT U.id, U.name AS username, CONCAT(  '$path', profile_pic )AS profile_pic, U.apn_id
        //         FROM  `follow` AS F
        //         JOIN users AS U ON F.users_id1 = U.id
        //         WHERE F.id =:follow_id";
        // $sth1=$conn->prepare($sql1);
<?php

//SAE有Cron服务,所以不需要这样循环了
//    ignore_user_abort(true);
//    set_time_limit(0);
echo "<h1>She Send Weibo</h1>";
date_default_timezone_set('Asia/Shanghai');
echo "</br>------" . date('Y-m-d H:i') . "--------</br>";
$allWeibo = getAllweibo();
$allFollowers = getAllFollowers();
foreach ($allFollowers as $follower) {
    $latestWeibo = getLatestWeibo($follower['latestWeibo_createdAt'], $follower['user_idstr'], $allWeibo);
    if (count($latestWeibo) > 0) {
        for ($i = count($latestWeibo) - 1; $i >= 0; $i--) {
            sendMessage($latestWeibo[$i]);
        }
        updateLatestWeiboCreatedTime($latestWeibo[0]->user->idstr, $latestWeibo[0]->created_at);
    } else {
        echo "no new weibo</br>";
    }
}
echo "</br>--------------------------------------</br>";
function getAllWeibo()
{
    $sina_api_url = "https://api.weibo.com/2/statuses/friends_timeline.json?access_token=2.00GAm1DGl5reKC5a97f4101fRNyi3B";
    echo "url:::::::::::   {$sina_api_url}</br>";
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $sina_api_url);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($curl);
Esempio n. 3
0
        if (!empty($result)) {
            $success = "1";
            $msg = "Following are the followers";
            $data = $result;
        } else {
            $success = "1";
            $msg = "No follower exist";
        }
    } else {
        $success = "0";
        $msg = "No such user exist!";
    }
} elseif (!empty($others_id)) {
    $others_id = checkUsersIdExist($others_id);
    if ($others_id) {
        $result = getAllFollowers($others_id);
        if (!empty($result)) {
            $success = "1";
            $msg = "Following are the followers";
            $data = $result;
        } else {
            $success = "1";
            $msg = "No follower exist";
        }
    } else {
        $success = "0";
        $msg = "No such user exist!";
    }
} else {
    $success = "0";
    $msg = "Incomplete parameters!";