I'm completely new to cURL and API's, but i'm attempting to build an application that uses GitHubs Code Search API.
in my XAMPP Shell, I can execute the below string with no problems
curl -u myuser https://api.github.com/search/code?q=XXX+language:XXX?access_token=XXX
Now, as i'm trying to use cURL in PHP i run into some problems, my code below:
$url = 'https://api.github.com/search/code?q=' . $term . 'language:' . $lang . 'stars:' . $stars . '?access_token=' . $token;
$cInit = curl_init();
curl_setopt($cInit, CURLOPT_URL, $url);
curl_setopt($cInit, CURLOPT_RETURNTRANSFER, 1); // 1 = TRUE
curl_setopt($cInit, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($cInit, CURLOPT_USERPWD, $user . ':' . $pwd);
$output = curl_exec($cInit);
$info = curl_getinfo($cInit, CURLINFO_HTTP_CODE);
$result = json_decode($output);
curl_close($cInit);
When i var_dump($result); The page greets me with a null value
I checked the HTTP_CODE with the below code:
$info = curl_getinfo($cInit, CURLINFO_HTTP_CODE);
var_dump($info);
Which then tells me int(403) which is 403 Forbidden which relates to something authentication related. What exactly am i doing wrong in this situation?