Beispiel #1
0
 $counter = 0;
 $delta = 0;
 $updatedata = array('last_email_at' => time());
 switch ($user['frequency']) {
     case 'monthly':
         $updatedata['next_email_at'] = strtotime(date('Y-m-' . $user['when'] . ' ' . $user['hour'] . ':i:s', strtotime('next month')));
         break;
     case 'weekly':
         $updatedata['next_email_at'] = strtotime(date('Y-m-d ' . $user['hour'] . ':i:s', strtotime('next ' . $user['when'])));
         break;
     case 'daily':
     default:
         $updatedata['next_email_at'] = strtotime(date('Y-m-d ' . $user['hour'] . ':i:s', time() + 86400));
         break;
 }
 $query = Followers::GetDiffs($user['username'], $user['last_email_at']);
 $changes = array('new' => array(), 'old' => array());
 if (empty($user['post_url'])) {
     $body_text = TPL('emails/body_text_header', array('username' => $user['username'], 'last_email_at' => $user['last_email_at']), true);
     $body_html = TPL('emails/body_html_header', array('username' => $user['username'], 'last_email_at' => $user['last_email_at']), true);
 }
 $currentlynew = 0;
 $new_text = '';
 $new_html = '';
 $ex_text = '';
 $ex_html = '';
 while ($row = mysql_fetch_assoc($query)) {
     // Update the user
     $twitteruser = Twitter::GetUserDetails($row['follower_id'], 'user_id');
     if (!$twitteruser or !$twitteruser->screen_name) {
         continue;
 /**
  * Stop following given userId
  */
 public function unfollowAction()
 {
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         throw new Zend_Auth_Exception("You're not authorized to see this page");
     }
     $userId = $this->_getParam('userId');
     $follower = $auth->getStorage()->read();
     if ($userId != $follower['id']) {
         $followers = new Followers($userId);
         $followers->remove($follower['id']);
         $following = new Following($follower['id']);
         $following->remove($userId);
     }
     $this->_redirect('/user/followers/userId/' . $userId);
 }
Beispiel #3
0
while (time() < $endtime) {
    $sleep = true;
    $user = User::GetNext();
    if ($user !== false) {
        $update_started_at = time();
        $num_followers = 0;
        $followers = Twitter::GetFollowers($user['username']);
        if ($followers === false) {
            User::Update($user['username'], array('last_run_at' => time()));
            User::Release();
            continue;
        }
        foreach ($followers as $f) {
            //TwitterUsers::Add($f);
            Followers::Add($user['username'], $f);
        }
        $num_followers += count($followers);
        Followers::Remove($user['username'], $update_started_at);
        $updatedata = array('last_run_at' => time(), 'follower_count' => $num_followers);
        // If we haven't sent an email yet make sure we set the last time to the future
        // so we don't notify them of all their existing followers
        if ($user['last_email_at'] == 0) {
            $updatedata['last_email_at'] = time() + 3600;
        }
        User::Update($user['username'], $updatedata);
        User::Release();
    }
    if ($sleep) {
        sleep(60);
    }
}
Beispiel #4
0
 /**
  * Main Followers Instance
  *
  * Ensures only one instance of Followers is loaded or can be loaded.
  *
  * @since 1.0.0
  * @static
  * @see Followers()
  * @return Main Followers instance
  */
 public static function instance()
 {
     if (is_null(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Beispiel #5
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.";
 protected final function process_request()
 {
     //	Process
     //
     if ($this->request_noun === REQUEST_NOUN_USERS) {
         if ($this->request_verb === 'show') {
             //	Show
             //
             if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) {
                 Users::show($this->inputter, $this->outputter);
             } else {
                 $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
             }
         } else {
             if ($this->request_verb === 'search' && $this->http_method === HTTP_METHOD_GET) {
                 //	Search
                 //
                 Users::search($this->inputter, $this->outputter);
             } else {
                 if ($this->request_verb === 'lookup' && $this->http_method === HTTP_METHOD_GET) {
                     //	Lookup
                     //
                     Users::lookup($this->inputter, $this->outputter);
                 } else {
                     $this->invalid_process_verb();
                 }
             }
         }
     } else {
         if ($this->request_noun === REQUEST_NOUN_FRIENDS) {
             if ($this->request_verb === 'list' && $this->http_method === HTTP_METHOD_GET) {
                 //	List
                 //
                 Friends::_list($this->inputter, $this->outputter);
             } else {
                 if ($this->request_verb === 'ids' && $this->http_method === HTTP_METHOD_GET) {
                     //	User IDs
                     //
                     Friends::ids($this->inputter, $this->outputter);
                 } else {
                     $this->invalid_process_verb();
                 }
             }
         } else {
             if ($this->request_noun === REQUEST_NOUN_FOLLOWERS) {
                 if ($this->request_verb === 'list' && $this->http_method === HTTP_METHOD_GET) {
                     //	List
                     //
                     Followers::_list($this->inputter, $this->outputter);
                 } else {
                     if ($this->request_verb === 'ids' && $this->http_method === HTTP_METHOD_GET) {
                         //	User IDs
                         //
                         Followers::ids($this->inputter, $this->outputter);
                     } else {
                         $this->invalid_process_verb();
                     }
                 }
             } else {
                 if ($this->request_noun === REQUEST_NOUN_IN_PRODUCT_PROMOTIONS) {
                     if ($this->request_verb === 'show') {
                         //	Show
                         //
                         if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) {
                             //	In Product Promotion ID
                             //
                             InProductPromotions::show($this->inputter, $this->outputter);
                         } else {
                             $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                         }
                     } else {
                         if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) {
                             //	Create
                             //
                             InProductPromotions::create($this->inputter, $this->outputter);
                         } else {
                             if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) {
                                 //	Update
                                 //
                                 InProductPromotions::update($this->inputter, $this->outputter);
                             } else {
                                 if ($this->request_verb === 'destroy') {
                                     //	Destroy
                                     //
                                     if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) {
                                         //	In Product Promotion ID
                                         //
                                         InProductPromotions::destroy($this->inputter, $this->outputter);
                                     } else {
                                         $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                     }
                                 } else {
                                     $this->invalid_process_verb();
                                 }
                             }
                         }
                     }
                 } else {
                     if ($this->request_noun === REQUEST_NOUN_INVITATIONS) {
                         if ($this->request_verb === 'show') {
                             //	Show
                             //
                             if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) {
                                 Invitations::show($this->inputter, $this->outputter);
                             } else {
                                 $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                             }
                         } else {
                             if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) {
                                 //	Create
                                 //
                                 Invitations::create($this->inputter, $this->outputter);
                             } else {
                                 if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) {
                                     //	Update
                                     //
                                     Invitations::update($this->inputter, $this->outputter);
                                 } else {
                                     if ($this->request_verb === 'destroy') {
                                         //	Destroy
                                         //
                                         if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) {
                                             //	Invitation ID
                                             //
                                             Invitations::destroy($this->inputter, $this->outputter);
                                         } else {
                                             $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                         }
                                     } else {
                                         if ($this->request_verb === 'incoming') {
                                             //	Incoming
                                             //
                                             if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'list' && $this->http_method === HTTP_METHOD_GET) {
                                                 //	List
                                                 //
                                                 Invitations::incoming_list($this->inputter, $this->outputter);
                                             } else {
                                                 $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                             }
                                         } else {
                                             if ($this->request_verb === 'outgoing') {
                                                 //	Outgoing
                                                 //
                                                 if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'list' && $this->http_method === HTTP_METHOD_GET) {
                                                     //	List
                                                     //
                                                     Invitations::outgoing_list($this->inputter, $this->outputter);
                                                 } else {
                                                     $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                                 }
                                             } else {
                                                 $this->invalid_process_verb();
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     } else {
                         if ($this->request_noun === REQUEST_NOUN_EVENT_OCCURRENCES) {
                             //	Event Occurrences
                             //
                             if ($this->request_verb === 'show') {
                                 //	Show
                                 //
                                 if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) {
                                     EventOccurrences::show($this->inputter, $this->outputter);
                                 } else {
                                     $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                 }
                             } else {
                                 if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) {
                                     //	Create
                                     //
                                     EventOccurrences::create($this->inputter, $this->outputter);
                                 } else {
                                     if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) {
                                         //	Update
                                         //
                                         EventOccurrences::update($this->inputter, $this->outputter);
                                     } else {
                                         if ($this->request_verb === 'destroy') {
                                             //	Destroy
                                             //
                                             if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) {
                                                 //	Event Occurrence ID
                                                 //
                                                 EventOccurrences::destroy($this->inputter, $this->outputter);
                                             } else {
                                                 $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                             }
                                         } else {
                                             if ($this->request_verb === 'list') {
                                                 //	List
                                                 //
                                                 if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'event' && $this->http_method === HTTP_METHOD_GET) {
                                                     //	Created
                                                     //
                                                     EventOccurrences::list_event($this->inputter, $this->outputter);
                                                 } else {
                                                     $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                                 }
                                             } else {
                                                 $this->invalid_process_verb();
                                             }
                                         }
                                     }
                                 }
                             }
                         } else {
                             if ($this->request_noun === REQUEST_NOUN_PHOTOS) {
                                 if ($this->request_verb === 'show') {
                                     //	Show
                                     //
                                     if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) {
                                         //	Photo ID
                                         //
                                         Photos::show($this->inputter, $this->outputter);
                                     } else {
                                         $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                     }
                                 } else {
                                     if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) {
                                         //	Create
                                         //
                                         Photos::create($this->inputter, $this->outputter);
                                     } else {
                                         if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) {
                                             //	Update
                                             //
                                             Photos::update($this->inputter, $this->outputter);
                                         } else {
                                             if ($this->request_verb === 'destroy') {
                                                 //	Destroy
                                                 //
                                                 if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) {
                                                     //	Photo ID
                                                     //
                                                     Photos::destroy($this->inputter, $this->outputter);
                                                 } else {
                                                     $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                                 }
                                             } else {
                                                 if ($this->request_verb === 'list' && $this->http_method === HTTP_METHOD_GET) {
                                                     //	List
                                                     //
                                                     Photos::_list($this->inputter, $this->outputter);
                                                 } else {
                                                     $this->invalid_process_verb();
                                                 }
                                             }
                                         }
                                     }
                                 }
                             } else {
                                 if ($this->request_noun === REQUEST_NOUN_ALBUMS) {
                                     if ($this->request_verb === 'show') {
                                         //	Show
                                         //
                                         if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) {
                                             //	Album ID
                                             //
                                             Albums::show($this->inputter, $this->outputter);
                                         } else {
                                             $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                         }
                                     } else {
                                         if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) {
                                             //	Create
                                             //
                                             Albums::create($this->inputter, $this->outputter);
                                         } else {
                                             if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) {
                                                 //	Update
                                                 //
                                                 Albums::update($this->inputter, $this->outputter);
                                             } else {
                                                 if ($this->request_verb === 'destroy') {
                                                     //	Destroy
                                                     //
                                                     if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) {
                                                         //	Album ID
                                                         //
                                                         Albums::destroy($this->inputter, $this->outputter);
                                                     } else {
                                                         $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                                     }
                                                 } else {
                                                     if ($this->request_verb === 'list' && $this->http_method === HTTP_METHOD_GET) {
                                                         //	List
                                                         //
                                                         Albums::_list($this->inputter, $this->outputter);
                                                     } else {
                                                         $this->invalid_process_verb();
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 } else {
                                     if ($this->request_noun === REQUEST_NOUN_SEARCH) {
                                         if ($this->http_method === HTTP_METHOD_GET) {
                                             if ($this->request_verb === 'list') {
                                                 //	Search
                                                 //
                                                 Search::search_list($this->inputter, $this->outputter);
                                             }
                                         }
                                     } else {
                                         if ($this->request_noun === REQUEST_NOUN_FOLLOWINGS) {
                                             if ($this->request_verb === 'list' && $this->http_method === HTTP_METHOD_GET) {
                                                 //	List
                                                 //
                                                 Followings::_list($this->inputter, $this->outputter);
                                             } else {
                                                 if ($this->request_verb === 'ids' && $this->http_method === HTTP_METHOD_GET) {
                                                     //	User IDs
                                                     //
                                                     Followings::ids($this->inputter, $this->outputter);
                                                 } else {
                                                     if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) {
                                                         //	Create
                                                         //
                                                         Followings::create($this->inputter, $this->outputter);
                                                     } else {
                                                         if ($this->request_verb === 'destroy' && $this->http_method === HTTP_METHOD_POST) {
                                                             //	User IDs
                                                             //
                                                             Followings::destroy($this->inputter, $this->outputter);
                                                         } else {
                                                             $this->invalid_process_verb();
                                                         }
                                                     }
                                                 }
                                             }
                                         } else {
                                             if ($this->request_noun === REQUEST_NOUN_ACCOUNT) {
                                                 if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) {
                                                     Account::create($this->inputter, $this->outputter);
                                                 } else {
                                                     if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) {
                                                         Account::update($this->inputter, $this->outputter);
                                                     } else {
                                                         if ($this->request_verb === 'destroy' && $this->http_method === HTTP_METHOD_DELETE) {
                                                             //	Destroy
                                                             //
                                                             if (isset($this->inputter->additional_uri_arguments[0]) && count($this->inputter->additional_uri_arguments) === 1) {
                                                                 Account::destroy($this->inputter, $this->outputter);
                                                             } else {
                                                                 // Throw error, identification is required
                                                                 //
                                                                 $error = Error::withDomain(PRIVATE_EVENTS_REST_CONTROLLER_ERROR_DOMAIN, ERROR_CODE_VALIDATION_PROPERTY_NOT_SET, 'A user identification is required.');
                                                                 $this->outputter->print_error($error);
                                                             }
                                                         } else {
                                                             if ($this->request_verb === 'authenticate' && $this->http_method === HTTP_METHOD_POST) {
                                                                 Account::authenticate($this->inputter, $this->outputter);
                                                             } else {
                                                                 if ($this->request_verb === 'unauthenticate' && $this->http_method === HTTP_METHOD_POST) {
                                                                     Account::unauthenticate($this->inputter, $this->outputter);
                                                                 } else {
                                                                     $this->invalid_process_verb();
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             } else {
                                                 if ($this->request_noun === REQUEST_NOUN_EVENTS) {
                                                     if ($this->request_verb === 'show') {
                                                         //	Show
                                                         //
                                                         if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_POST) {
                                                             Events::show($this->inputter, $this->outputter);
                                                         } else {
                                                             $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                                         }
                                                     } else {
                                                         if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) {
                                                             //	Create
                                                             //
                                                             Events::create($this->inputter, $this->outputter);
                                                         } else {
                                                             if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) {
                                                                 //	Update
                                                                 //
                                                                 Events::update($this->inputter, $this->outputter);
                                                             } else {
                                                                 if ($this->request_verb === 'destroy') {
                                                                     //	Destroy
                                                                     //
                                                                     if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) {
                                                                         //	Event ID
                                                                         //
                                                                         Events::destroy($this->inputter, $this->outputter);
                                                                     } else {
                                                                         $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                                                     }
                                                                 } else {
                                                                     if ($this->request_verb === 'attend' && $this->http_method === HTTP_METHOD_POST) {
                                                                         //  Attend
                                                                         //
                                                                         Events::attend($this->inputter, $this->outputter);
                                                                     } else {
                                                                         if ($this->request_verb === 'search' && $this->http_method === HTTP_METHOD_GET) {
                                                                             //	Search
                                                                             //
                                                                             Events::search($this->inputter, $this->outputter);
                                                                         } else {
                                                                             if ($this->request_verb === 'list') {
                                                                                 //	List
                                                                                 //
                                                                                 if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'event_type' && $this->http_method === HTTP_METHOD_GET) {
                                                                                     //	Event Type
                                                                                     //
                                                                                     Events::list_event_type($this->inputter, $this->outputter);
                                                                                 } else {
                                                                                     if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'created' && $this->http_method === HTTP_METHOD_GET) {
                                                                                         //	Created
                                                                                         //
                                                                                         Events::list_created($this->inputter, $this->outputter);
                                                                                     } else {
                                                                                         if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'invited' && $this->http_method === HTTP_METHOD_GET) {
                                                                                             //	Invited
                                                                                             //
                                                                                             Events::list_invited($this->inputter, $this->outputter);
                                                                                         } else {
                                                                                             if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'nearby' && $this->http_method === HTTP_METHOD_GET) {
                                                                                                 //	Nearby
                                                                                                 //
                                                                                                 Events::list_nearby($this->inputter, $this->outputter);
                                                                                             } else {
                                                                                                 if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'popular' && $this->http_method === HTTP_METHOD_GET) {
                                                                                                     //	Popular
                                                                                                     //
                                                                                                     Events::list_popular($this->inputter, $this->outputter);
                                                                                                 } else {
                                                                                                     $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             } else {
                                                                                 $this->invalid_process_verb();
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 } else {
                                                     if ($this->request_noun === REQUEST_NOUN_LOCATIONS) {
                                                         if ($this->request_verb === 'show') {
                                                             //	Show
                                                             //
                                                             if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) {
                                                                 //	Location ID
                                                                 //
                                                                 Locations::show($this->inputter, $this->outputter);
                                                             } else {
                                                                 $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                                             }
                                                         } else {
                                                             if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) {
                                                                 //	Create
                                                                 //
                                                                 Locations::create($this->inputter, $this->outputter);
                                                             } else {
                                                                 if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) {
                                                                     //	Update
                                                                     //
                                                                     Locations::update($this->inputter, $this->outputter);
                                                                 } else {
                                                                     if ($this->request_verb === 'destroy') {
                                                                         //	Destroy
                                                                         //
                                                                         if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) {
                                                                             //	Location ID
                                                                             //
                                                                             Locations::destroy($this->inputter, $this->outputter);
                                                                         } else {
                                                                             $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                                                         }
                                                                     } else {
                                                                         $this->invalid_process_verb();
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     } else {
                                                         if ($this->request_noun === REQUEST_NOUN_TICKETS) {
                                                             if ($this->request_verb === 'show') {
                                                                 //	Show
                                                                 //
                                                                 if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_GET) {
                                                                     //	Ticket ID
                                                                     //
                                                                     Tickets::show($this->inputter, $this->outputter);
                                                                 } else {
                                                                     $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                                                 }
                                                             } else {
                                                                 if ($this->request_verb === 'create' && $this->http_method === HTTP_METHOD_POST) {
                                                                     //	Create
                                                                     //
                                                                     Tickets::create($this->inputter, $this->outputter);
                                                                 } else {
                                                                     if ($this->request_verb === 'update' && $this->http_method === HTTP_METHOD_POST) {
                                                                         //	Update
                                                                         //
                                                                         Tickets::update($this->inputter, $this->outputter);
                                                                     } else {
                                                                         if ($this->request_verb === 'destroy') {
                                                                             //	Destroy
                                                                             //
                                                                             if (count($this->inputter->additional_uri_arguments) === 1 && isset($this->inputter->additional_uri_arguments[0]) && $this->http_method === HTTP_METHOD_DELETE) {
                                                                                 //	Ticket ID
                                                                                 //
                                                                                 Tickets::destroy($this->inputter, $this->outputter);
                                                                             } else {
                                                                                 $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                                                             }
                                                                         } else {
                                                                             if ($this->request_verb === 'outgoing') {
                                                                                 //	Outgoing
                                                                                 //
                                                                                 if (count($this->inputter->additional_uri_arguments) === 1 && $this->inputter->additional_uri_arguments[0] === 'list' && $this->http_method === HTTP_METHOD_GET) {
                                                                                     //	List
                                                                                     //
                                                                                     Tickets::outgoing_list($this->inputter, $this->outputter);
                                                                                 } else {
                                                                                     $this->invalid_process_additional_argument(count($this->inputter->additional_uri_arguments) - 1);
                                                                                 }
                                                                             } else {
                                                                                 $this->invalid_process_verb();
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         } else {
                                                             $this->invalid_process_noun();
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #7
0
<?php

/**
 * Followers
 * url - /followers/list
 * method - GET
 */
$app->get('/followers/list', 'authenticate', function () use($app) {
    global $user_id;
    $response = array();
    $db = new Followers();
    $results = $db->getFollowers($user_id);
    $records = array();
    //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'] = $db->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.";
        $response['items'] = $records;