示例#1
0
 /**
  * Display suggestion list.
  *
  * @return Response
  */
 public function follow_suggestion($userId)
 {
     $user = Account::find($userId);
     $url = "";
     //if($user != null)
     $url = 'http://candychat.net/request.php?t=search&a=follow-suggestions-mobile&user_id=' . $user->id . "&user_pass="******"&token=asdffdsa&q=a";
     $api_response = cURL::get($url);
     $response = $api_response->toArray();
     $response = $response['body'];
     $json = json_decode($response, true);
     //return Response::json($json);
     $total_account = sizeof($json["suggestion"]);
     $users = array();
     foreach ($json["suggestion"] as $user) {
         $the_user = Account::find((int) $user["id"]);
         $the_user->avatar;
         $the_user->cover;
         $the_user->gender;
         $the_user->birthday;
         $the_user->is_following = Helpers::SK_isFollowing($the_user->id, $userId);
         $users[] = $the_user;
     }
     $response = array('status' => '1', 'total' => $total_account, 'users' => $users);
     return Response::json($response);
 }
示例#2
0
 public function follow($id)
 {
     $params = array('following_id' => $id);
     $url = 'https://www.vdomax.com/ajax.php?t=follow&a=follow&user_id=' . $this->user->id . "&user_pass="******"&token=" . $this->api_token;
     $api_response = cURL::post($url, $params);
     $response = $api_response->toArray();
     $response = $response['body'];
     $json = json_decode($response, true);
     if ($json['status'] == 200) {
         if (Helpers::SK_isFollowing($id, $this->user->id)) {
             $response = array('status' => '1', 'message' => "Follow success", 'user_id' => $id, 'is_following' => Helpers::SK_isFollowing($id, $this->user->id));
         } else {
             $response = array('status' => '1', 'message' => "Unfollow success", 'user_id' => $id, 'is_following' => Helpers::SK_isFollowing($id, $this->user->id));
         }
     } else {
         $response = array('status' => '0', 'message' => "Follow/Unfollow incomplete");
     }
     return Response::json($response);
 }
示例#3
0
 public static function SK_getSearchMobile($search_query = '', $userId = 0, $from_row = 0, $limit = 50)
 {
     global $dbConnect;
     $dbConnect = Helpers::dbConnect();
     $get = array();
     $get['story'] = array();
     $get['user'] = array();
     $get['hashtag'] = array();
     if (!isset($search_query) or empty($search_query)) {
         return $get;
     }
     if (!isset($from_row) or empty($from_row)) {
         $from_row = 0;
     }
     if (!is_numeric($from_row) or $from_row < 0) {
         return $get;
     }
     if (!isset($limit) or empty($limit)) {
         $limit = 10;
     }
     if (!is_numeric($limit) or $limit < 1) {
         return $get;
     }
     $search_query = Helpers::SK_secureEncode($search_query);
     $from_row = Helpers::SK_secureEncode($from_row);
     $limit = Helpers::SK_secureEncode($limit);
     $query_one = "SELECT id FROM " . DB_ACCOUNTS_API . " WHERE (email LIKE '%{$search_query}%' OR username LIKE '{$search_query}' " . " OR name LIKE '%{$search_query}%'" . ") " . " AND (id IN (SELECT id FROM " . DB_USERS_API . ") " . " OR id IN (SELECT id FROM " . DB_PAGES_API . ") " . " OR id IN (SELECT id FROM " . DB_GROUPS_API . " WHERE group_privacy IN ('open','closed'))) " . "AND type IN ('user','page','group') " . " AND active=1 ORDER BY " . "CASE\n    WHEN username LIKE '{$search_query}%' THEN 1\n    WHEN username LIKE '%{$search_query}' THEN 3\n    ELSE 2\n  END" . " ASC LIMIT {$from_row},{$limit}";
     $sql_query_one = mysqli_query($dbConnect, $query_one);
     if (mysqli_num_rows($sql_query_one) > 0) {
         while ($sql_fetch_one = mysqli_fetch_assoc($sql_query_one)) {
             //$get['user'][] = SK_getUser($sql_fetch_one['id']);
             $user = Account::find($sql_fetch_one['id']);
             $user->avatar;
             $user->cover;
             $user->gender;
             $user->birthday;
             //$data['author'] = $post->account;
             if ($userId != 0) {
                 $user->is_following = Helpers::SK_isFollowing($user->id, $userId);
             } else {
                 $user->is_following = false;
             }
             $user->online = false;
             $get['user'][] = $user;
         }
     }
     //
     $hashdata = Helpers::SK_getHashtag($search_query);
     $postIds = Helpers::SK_getHashtagPostsArray($hashdata);
     foreach ($postIds as $postId) {
         $get['story'][] = Helpers::getPost($postId);
     }
     $query_one = "SELECT id FROM " . DB_POSTS_API . " WHERE youtube_title LIKE '%{$search_query}%' ORDER BY youtube_title ASC LIMIT {$from_row},{$limit}";
     $sql_query_one = mysqli_query($dbConnect, $query_one);
     if (mysqli_num_rows($sql_query_one) > 0) {
         while ($sql_fetch_one = mysqli_fetch_assoc($sql_query_one)) {
             //$get['story'][] = Post::find($sql_fetch_one['id']);
             $get['story'][] = Helpers::getPost($sql_fetch_one['id']);
         }
     }
     $get['hashtag'] = Helpers::SK_getHashtagSearch($search_query);
     if (count($get['story']) == 0 || $get['story'] == null) {
         $get['story'] = array();
     }
     if (count($get['user']) == 0 || $get['user'] == null) {
         $get['user'] = array();
     }
     if (count($get['hashtag']) == 0 || $get['hashtag'] == null) {
         $get['hashtag'] = array();
     }
     //
     return $get;
 }
示例#4
0
 /**
  * Display the specified by username.
  *
  * @param  int  $username
  * @return Response
  */
 public function check($username)
 {
     if (filter_var($username, FILTER_VALIDATE_EMAIL)) {
         $user = Account::where('email', $username)->get()->first();
     } else {
         $user = Account::where('username', $username)->get()->first();
     }
     if ($user != null) {
         $user->avatar;
         $user->cover;
         $user->birthday;
         $user->gender;
         $params = Input::all();
         if (isset($params['user_id'])) {
             $user->is_following = Helpers::SK_isFollowing($user->id, $params['user_id']);
         }
         return Response::json(array('status' => '1', 'user' => $user));
     } else {
         return Response::json(array('status' => '0', 'user' => null, 'count' => null));
     }
     if ($user->count() > 0) {
         return Response::json(array('status' => '1', 'user' => $user));
     } else {
         return Response::json(array('status' => '0', 'message' => 'No user found'));
     }
 }