Hello,
I’m really new, but I cannot figure out where to find what I’m looking for to get this response working correctly with the User Object.
I’ve set up the Get Token(saw on a previous forum topic).
$auth_token = “https://api.twitch.tv/kraken/oauth2/authorize?response_type=code&client_id=&redirect_uri=&scope=user_read+chat_login”;
//This gets used below.
if(isset($_GET[“code”])){
$user_code = $_GET[“code”];
}
$curl = curl_init();
$arr = array(
‘client_id’ => ‘’,
‘client_secret’ => ‘’,
‘grant_type’ => ‘authorization_code’, // Was told to not change this.
‘redirect_uri’ => ‘’,
‘code’ => $user_code, //code from above.
‘state’ => NULL
);
curl_setopt_array($curl, array(
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_FOLLOWLOCATION => FALSE,
CURLOPT_URL => ‘https://api.twitch.tv/kraken/oauth2/token/’,
CURLOPT_POSTFIELDS => $arr,
CURLOPT_RETURNTRANSFER => TRUE
));
$resp = curl_exec($curl);
curl_close($curl);
echo var_dump($resp);
I get JSON like this:
{
“access_token”: “”, // This is different what’s seen in the window.location (could be something wrong?)
“scope”://This matches what I put for scopes.
}
So where I get caught, is getting User Object with this syntax:
curl -H ‘Accept: application/vnd.twitchtv.v5+json’
-H ‘Client-ID: uo6dggojyb8d6soh92zknwmi5ej1q2’
-H ‘Authorization: OAuth cfabdegwdoklmawdzdo98xt2fo512y’
-X GET ‘https://api.twitch.tv/kraken/user’
I’m sure it’s obvious, but I’m new to cURL, and not sure how to write that on my php server to get user json
{
“_id”: 44322889,
“bio”: “Just a gamer playing games and chatting. :)”,
“created_at”: “2013-06-03T19:12:02Z”,
“display_name”: “dallas”,
“email”: "email-address@provider.com",
“email_verified”: true,
“logo”: “https://static-cdn.jtvnw.net/jtv_user_pictures/dallas-profile_image-1a2c906ee2c35f12-300x300.png”,
“name”: “dallas”,
“notifications”: {
“email”: false,
“push”: true
},
“partnered”: false,
“twitter_connected”: false,
“type”: “staff”,
“updated_at”: “2016-12-14T01:01:44Z”
}
All of this was copied from the documents and forum posts.