Exemplo n.º 1
0
 public function timeline($meUserId, $get)
 {
     $this->load->model('Status_model', 'StatusModel', TRUE);
     $this->load->model('Friend_model', 'FriendModel', TRUE);
     $limit = array_key_exists('limit', $get) ? $get['limit'] <= 30 ? $get['limit'] : 30 : 20;
     $sinceId = array_key_exists('since_id', $get) ? $get['since_id'] : null;
     $untilId = array_key_exists('until_id', $get) ? $get['until_id'] : null;
     $timelineUsers = $this->FriendModel->GetFollowings($meUserId);
     $timelineUsers[] = $meUserId;
     $statuses = $this->StatusModel->Find($timelineUsers, $limit, $sinceId, $untilId);
     $res = BuildSuccessResponse(["message" => "successful.", 'statuses' => !$statuses ? [] : $statuses]);
     return $res;
 }
 public function logout()
 {
     header("Content-Type: application/json; charset=utf-8");
     if (!CheckReferer($this->agent)) {
         return;
     }
     $isLogin = $this->session->userdata("is_login");
     if ($isLogin) {
         $this->session->sess_destroy();
         $res = BuildSuccessResponse("successful.");
     } else {
         $res = BuildErrorResponse(400, 106, "Please request with login.");
     }
     echo $res;
 }
Exemplo n.º 3
0
 public function friendstatus($meScreenName, $meUserId, $get)
 {
     $this->load->model("Account_model", "AccountModel", TRUE);
     $this->load->model("Friend_model", "FriendModel", TRUE);
     if (!ApiParamValidate($get, ["screen_name"])) {
         return;
     }
     $screenName = urldecode($get["screen_name"]);
     if (preg_match("/^[a-z0-9_]+\$/i", $screenName) === 1) {
         if ($screenName !== $meScreenName) {
             if ($target = $this->AccountModel->FindByScreenName($screenName)) {
                 $isFollower = $this->FriendModel->IsExist($target["id"], $meUserId);
                 $isFollowing = $this->FriendModel->IsExist($meUserId, $target["id"]);
                 $res = BuildSuccessResponse(["message" => "successful.", "is_follower" => $isFollower, "is_following" => $isFollowing]);
             } else {
                 $res = BuildErrorResponse(400, 200, "User not found.");
             }
         } else {
             $res = BuildErrorResponse(400, 201, "This user is you.");
         }
     } else {
         $res = BuildErrorResponse(400, 102, "Some invalid parameters.");
     }
     return $res;
 }