Last active
August 3, 2017 13:20
-
-
Save slick2/a16d81dd3693a70fefa92742d12a8d33 to your computer and use it in GitHub Desktop.
sample ajax method
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
class Users{ | |
public function xhr_contactList(){ | |
//make a curl call | |
$url = https://www.namesilo.com/api/contactList?version=1&type=json&key=12345 | |
//response | |
$result = $this->_http_get($url); | |
$return = json_decode($result); | |
echo $return; | |
} | |
private function _http_get($url) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array()); | |
curl_setopt($ch, CURLOPT_VERBOSE, 1); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
$response = curl_exec($ch); | |
curl_close($ch); | |
return $response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment