Skip to content

Instantly share code, notes, and snippets.

@MikSDigital
Last active February 20, 2017 14:58
Show Gist options
  • Save MikSDigital/f0c962002e67b119a2ef83c082f1d6ed to your computer and use it in GitHub Desktop.
Save MikSDigital/f0c962002e67b119a2ef83c082f1d6ed to your computer and use it in GitHub Desktop.
Requets example (send POST data)
<?php
private function sendRequest($URL)
{
return Requests::get($URL, $this->headers, $this->options)->body;
}
// Getting form values
$allFormFields = array(
'name' => $hook->getValue('Name'),
'surname' => $hook->getValue('Surname'),
'company' => $hook->getValue('Companyname'),
'email' => $hook->getValue('Email'),
'country' => $countryCode
);
$headers = array('Accept' => 'application/json');
try {
$response = Requests::post($apiURL, $headers, $allFormFields);
var_dump ($response->body);
die();
} catch(Exception $e) {
echo $e->getMessage();
die();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment