https://docs.inpost24.com/display/PL/%5B1.2...aprzesy%C5%82ki
<?php
require_once 'vendor/restApi.php';
$restApi = new RestApi(array(
));
print_r($restApi->getResponse());
print_r(json_decode($restApi->getResponse()));
?>
Poniżej restApi.php
<?php class RestApi { protected $response; protected $info; protected $errno; protected $error; public function __construct($params) { 'token' => $params['token'], 'url' => $params['url'], 'methodType' => $params['methodType'], 'params' => $params['params'] )); } { $ch = curl_init(); switch($params['methodType']){ case 'GET': $getParams = null; foreach($params['params'] as $field_name => $field_value){ } curl_setopt($ch, CURLOPT_URL, $params['url'].'?'.$getParams); }else{ curl_setopt($ch, CURLOPT_URL, $params['url'].'?'.$params['token']); } curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); break; case 'POST': $string = json_encode($params['params']); #$string = $params['params']; curl_setopt($ch, CURLOPT_URL, $params['url'].'?token='.$params['token']); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $string); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); 'Content-Type: application/json', ); break; case 'PUT': $string = json_encode($params['params']); #$string = $params['params']; curl_setopt($ch, CURLOPT_URL, $params['url'].'?token='.$params['token']); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $string); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); 'Content-Type: application/json', ); break; } curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); $this->info = curl_getinfo($ch); $this->errno = curl_errno($ch); $this->error = curl_error($ch); if ($this->info['http_code'] != 200) { 'message' => 'Request failed', 'type' => 'RequestErrors', 'code_errors' => $this->config['errorCodes'][$info['http_code']] )); } return $result; } public function getResponse() { return $this->response; } public function getInfo() { return $this->info; } public function getErrno() { return $this->errno; } public function getError() { return $this->error; } } ?>
Nikt nie wie ?
