Ejemplo n.º 1
0
 function setCommand($method = null, $params = array())
 {
     if (is_null($method)) {
         $method = 'GET';
     }
     $arr = array(CURLOPT_CUSTOMREQUEST => $method);
     if (!empty($params)) {
         $arr = \PMVC\array_merge($arr, $params);
     }
     $this->command =& $arr;
 }
Ejemplo n.º 2
0
 public function request($path, $params = array())
 {
     $respond = null;
     $url = $this->getBaseUrl() . $path;
     $params = \PMVC\array_merge(array(CURLOPT_USERPWD => $this->auth), $params);
     $curl = \PMVC\plug('curl');
     $curl->get($url, function ($r) use(&$respond, $url) {
         if (400 >= $r->code) {
             $respond = (object) array('header' => $r->header, 'body' => json_decode($r->body));
         } else {
             trigger_error('Get result error. Error Code:' . $r->code . ' url: ' . $url);
         }
     })->set($params);
     $curl->run();
     return $respond;
 }