public function post($url, $raw = true) { return $this->_httpRequest('POST', $url, $raw); }
/** * @param $username * @param $password * @return array Success { * @var string AccessId * @var string SecretKey * @var string UserId * @var string EmployeeId * } * @throws MPAuthException */ public function authenticate($username, $password) { $data = ['Login' => $username, 'Password' => md5($password)]; $this->prepareRequest($data); try { $response = $this->curl->post($this->url . $this->authRelativeUrl, true); try { $decodedResponse = Json::decode($response, true); switch ($decodedResponse['status']['code']) { case 'ok': break; case 'error': throw new MPAuthException('Invalid username or password.'); break; default: throw new MPAuthException('Unknown response status.'); } return $decodedResponse['data']; } catch (InvalidParamException $e) { throw new MPAuthException('Error decoding server response. Raw response: ' . var_export($response, true)); } } catch (Exception $e) { throw new MPAuthException('Error requesting host:' . $e->getMessage() . $e->getCode()); } }