Last active
December 20, 2015 15:19
-
-
Save jeremywrowe/6153397 to your computer and use it in GitHub Desktop.
This is an example of querying the chargify api and retrieving the status code of the response
This file contains 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 | |
$api_key = ""; | |
$subdomain = ""; | |
$handle = curl_init('https://'.$subdomain.'.chargify.com/customers/100000.json'); | |
curl_setopt($handle, CURLOPT_USERPWD, $api_key . ":x"); | |
curl_setopt($handle, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); | |
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true); | |
$response = curl_exec($handle); | |
$info = curl_getinfo($handle); | |
echo 'Status Code: ' . $info['http_code'] . PHP_EOL; // was it 200 (successful) | |
echo 'Content-Type: ' . $info['content_type'] . PHP_EOL; // showing that json was indeed returned | |
echo 'Response: ' . $response . PHP_EOL; | |
curl_close($handle); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment