Wallogit.com
2017 © Pedro Peláez
A simple PHP class for submitting REST requests via cURL.
A PHP class for submitting REST requests via cURL., (*1)
Open the RestRequestConfig.php class and set the $baseUrl parameter to be the base URL of the API. Here, you can also set a default format for the request body (JSON or Form-encoded)., (*2)
Define a new client like this:, (*3)
$request = new \ParamoreDigital\RestRequest();, (*4)
You can set cURL options like this:, (*5)
$request->setHttpOptions(array(CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => 'username:password'));, (*6)
You can set parameters like this:, (*7)
$request->setParams(array('firstName' => 'Ben', 'lastName' => 'Wilkins'));, (*8)
You can manually set an endpoint:, (*9)
$request->setEndPoint('/some/endpoint');
$request->post();
Or, you can pass the endpoint straight into the action method:, (*10)
$request->post('/some/endpoint');, (*11)