예제 #1
0
<?php

/**
 * Friends
 * url - /friends/list
 * method - GET
 */
$app->get('/friends/list', 'authenticate', function () use($app) {
    global $user_id;
    $response = array();
    $db = new Friends();
    $results = $db->getFriends($user_id);
    $records = array();
    $followers = new Followers();
    //echo "Successfully retrieved " . count($results) . " scores.<br><br>";
    // Do something with the returned ParseObject values
    for ($i = 0; $i < count($results); $i++) {
        $object = $results[$i];
        $record = array();
        $records[$i]['userId'] = $object->getObjectId();
        $records[$i]['firstName'] = $object->get('firstName');
        $records[$i]['lastName'] = $object->get('lastName');
        $records[$i]['username'] = $object->get('username');
        $records[$i]['email'] = $object->get('email');
        $records[$i]['following'] = $followers->isFollowing($object->getObjectId());
        //echo $object->getObjectId() . ' - ' . $object->get('username') . '<br>';
    }
    // check for records returned
    if ($records) {
        $response["result"] = "success";
        $response['message'] = count($records) . " users found.";
예제 #2
0
 /**
  * get people this user is following
  *
  * @param int $user_id
  * @param string $return - return 'array' of users of prepared 'query'
  * @return array|string
  */
 public function getFollowing($user_id = 0, $return = 'array')
 {
     require_once LIBS . 'Friends.php';
     $friends = new Friends();
     return $friends->getFriends($this, $user_id, 'following', $return);
 }