How I make a call to a non authenticated API request would be something like this in PHP.
$URLResult = file_get_contents(“https://api.twitch.tv/kraken?oauth_token=”.$token);
$decodedURL = json_decode($URLResult, true);
return $decodedURL[‘token’][‘user_name’];
Im not sure how I would connect them to make a call for something like:
curl -H ‘Accept: application/vnd.twitchtv.v3+json’ -H ‘Authorization: OAuth <access_token>’
-X GET https://api.twitch.tv/kraken/channel
I don’t work directly with cURL but I believe those two methods are independent of each other - You can make an API call either via PHP, PHP w/ cURL Library, or cURL (command line).
The PHP code you listed should work as long as the oauth has proper scope for what you are trying to pull.
An example of PHP w/ cURL Library is in the Client ID Blog :
So, if you are looking to include cURL in your PHP then you best bet is to focus on the including the cURL library and going with those examples.
What information are you trying to pull or what are you trying to do in the end? Some direction might also help someone else if they have better help to give than I. If you are just looking to make authenticated calls, the code included should suffice.
On a side note, was there anything wrong with your initial PHP statement to pull desired info or is there a technical reason you are looking to include cURL?
Your code works for me to pull a users email using OAUTH with user_read scope (modified slightly as I don’t have your code that engages it – ClientID and OAUTH are interchangeable up until you are trying to access information that a user needs to give the OK):