A simplification of the curl commands
This allows for a reusable templating structure that can accomodate most general needs.
To include the CurlClass in your composer file add the repo directory into your repositories section in the composer file and add the name of the module into the require section of the composer file.
"repositories": {
...
{
"type": "vcs",
"url": "https://github.com/fufu70/CurlClass.git"
}
...
}
...
"require": {
...
"fufu70/curl-class": "dev-master",
...
}
To send a get Request pass the endpoint and the data to the Curl::get
command
<?php
use Common\Curl;
$response = Curl::get(
'https://example.com/endpoint'
[
'name' => 'value',
'another_name' => 'another_value'
]
);
The post request (Curl::post
) works excactly the same way, except for the function name.
<?php
use Common\Curl;
$response = Curl::post(
'https://example.com/endpoint'
[
'name' => 'value',
'another_name' => 'another_value'
]
);