Reputation: 722
I would like to know what's the easiest to way to transform my code below to use cURL.
I'm asking this because I have performed every test in localhost and it was working fine until I pushed it to my server and I have read that I should use cURL but it looks so complicated for what I need to do.
$userid = file_get_contents("http://www.someexample.com/api/findusers/".$names."?key=".$key, NULL, NULL, 8);
Upvotes: 0
Views: 1006
Reputation: 2486
Here are the simplest way to perform a get request:
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.someexample.com/api/findusers/".$names."?key=".$key);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$userID = curl_exec($ch);
curl_close($ch);
?>
Upvotes: 1