function getByPhoneNum() { if (!($phone = $_REQUEST['From'])) { Error::sms("The SMS sender's phone number was not detected."); } if (!($body = $_REQUEST['Body'])) { Error::sms("Missing email address."); } $sql = "SELECT user_id, email, wallet FROM users WHERE phone=?"; $row = DBquery::get($sql, array($phone)); if ($row) { if ($body != $row[0]['email']) { Error::sms("The email address does not match the one set for phone #{$phone}."); } else { $this->user_id = $row[0]['user_id']; Requester::$consumer_id = $row[0]['wallet']; return $this->setToken(); } } else { require_once "models/UserCollection.php"; $Users = new UserCollection(json_decode('{ "email": "' . $body . '", "name": "' . $body . '", "password": "******", "phone": "' . $phone . '", "login_provider": "phone", "wallet": 2 }')); $arr = $Users->add(); $this->user_id = $arr[0]->user_id; return $this->setToken(); } }