Last active
February 20, 2017 14:58
-
-
Save MikSDigital/f0c962002e67b119a2ef83c082f1d6ed to your computer and use it in GitHub Desktop.
Requets example (send POST data)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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