コード例 #1
0
ファイル: Rest.php プロジェクト: ralts00/compropago-php
 /**
  * 
  * @param array $auth
  * @param Compropago\Client $client
  * @param string $service
  * @param string $query
  * @param string $method
  * @returns Array
  */
 public static function doExecute(Client $client, $service = null, $query = FALSE, $method = 'GET')
 {
     if (!isset($client)) {
         throw new Exception('Client Required');
     }
     $request = $client->getHttp();
     switch ($method) {
         case 'GET':
         case 'POST':
             //supp rest methods
             $request->setRequestMethod($method);
             break;
         default:
             //no more in rest
             throw new Exception('Rest Method not supported');
     }
     $request->setServiceUrl($service);
     if ($query && $method == 'POST') {
         //just post data, throw con query en GET?
         $request->setData($query);
     }
     $request->setMethodOptions($method);
     //$request->setOptions($addopts);
     $curl = new Curl();
     $response = $curl->executeRequest($request);
     //eval aca, errors parse data, http codes fatal exceptions,etc
     return $response['responseBody'];
 }
コード例 #2
0
ファイル: Service.php プロジェクト: vegamx/compropago-php
 /**
  * 
  * @param GuzzleHttp\Client $client
  */
 public function __construct(Compropago\Client $client)
 {
     $this->client = $client->getHttp();
     $this->auth = $client->getAuth();
 }