Example #1
0
 public function getToken()
 {
     $username = self::CONFIG_USERNAME;
     $password = self::CONFIG_PASSWORD;
     $time = time();
     $hash = md5("{$username}@{$password}@{$time}");
     $auth = "{$username}@{$time}@{$hash}";
     $ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '';
     $url = 'http://axe.mappy.com/1v1/token/generate.aspx?' . 'auth=' . urlencode($auth) . '&' . 'ip=' . urldecode($ip);
     /**
             $remote = @fopen($url, 'rb');
     
             if ( false === $remote )
        return false;
     
             $token = '';
     
             while ( !( feof($remote) ) )
        $token .= fread($remote, 8192);
     
             fclose($remote);
     */
     $curl = new Curl($url);
     $curl->request();
     $resp = $curl->response();
     $curl->disconnect();
     return $resp['body'];
 }
Example #2
0
 protected function request($url)
 {
     $curl = new Curl($url);
     $curl->request();
     $this->response = $curl->response();
     $curl->disconnect();
     if ($this->response['status']) {
         if ($this->response['status']['code'] == 200) {
             return $this->response['body'];
         }
         throw new Exception($this->response['status']['message'], $this->response['status']['code']);
     }
     throw new Exception('Error!');
 }
Example #3
0
 protected function request($url, $post = false)
 {
     if (true === $post || is_array($post)) {
         $curl = new Curl($url, CURLOPT_POST, true === $post ? array() : $post);
     } else {
         $curl = new Curl($url);
     }
     $curl->request();
     $this->response = $curl->response();
     $curl->disconnect();
     if ($this->response['status']) {
         if ($this->response['status']['code'] == 200) {
             return $this->response['body'];
         }
         throw new Exception($this->response['status']['message'], $this->response['status']['code']);
     }
     throw new Exception('Error!');
 }