I am able fetch github release details using curl but I want to do this using php.
The command I use in curl is the following:
curl -u user.ca:password -X GET https://api.github.com/repos/xyz/abc/releases
I am able fetch github release details using curl but I want to do this using php.
The command I use in curl is the following:
curl -u user.ca:password -X GET https://api.github.com/repos/xyz/abc/releases
The php equivalent of the -u
option is CURLOPT_USERPWD
.
curl_setopt($ch, CURLOPT_USERPWD, 'user.ca:password');
In the end you will have something like this:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.github.com/repos/xyz/abc/releases");
curl_setopt($ch, CURLOPT_USERPWD, 'user.ca:password');
curl_setopt($ch, CURLOPT_USERAGENT,'Awesome-Octocat-App');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$fetch = curl_exec($ch);
curl_close($ch);