This is the function I am using to get the user_name as of right now. I get it with $response[‘token’][‘user_name’] and it works for that, however, I am not seeing the rest of the data shown here in the documentation.
So I use this:
function authenticated_user($access_token) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->base_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: OAuth '.$access_token
));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$output = curl_exec($ch);
$response = json_decode($output, true);
curl_close($ch);
if(isset($response['token']['error'])) {
return 'Unauthorized';
} else {
return $response;
}
}
I get this:
Array (
[identified] => 1
[_links] => Array ( [user] => https://api.twitch.tv/kraken/user [channel] => https://api.twitch.tv/kraken/channel [search] => https://api.twitch.tv/kraken/search [streams] => https://api.twitch.tv/kraken/streams/username[ingests] => https://api.twitch.tv/kraken/ingests [teams] => https://api.twitch.tv/kraken/teams [users] => https://api.twitch.tv/kraken/users/username [channels] => https://api.twitch.tv/kraken/channels/username[chat] => https://api.twitch.tv/kraken/chat/username)
[token] =>
Array (
[valid] => 1
[authorization] => Array ( [scopes] => Array ( [0] => channel_read [1] => user_read ) [created_at] => 2016-07-09T16:05:32Z [updated_at] => 2016-07-09T16:05:32Z ) [user_name] => username) )
But what I want is this shown here. https://github.com/justintv/Twitch-API/blob/master/v3_resources/users.md
{
“type”: “user”,
“name”: “test_user1”,
“created_at”: “2011-06-03T17:49:19Z”,
“updated_at”: “2012-06-18T17:19:57Z”,
“_links”: {
“self”: “https://api.twitch.tv/kraken/users/test_user1”
},
“logo”: “http://static-cdn.jtvnw.net/jtv_user_pictures/test_user1-profile_image-62e8318af864d6d7-300x300.jpeg”,
“_id”: 22761313,
“display_name”: “test_user1”,
“email”: "asdf@asdf.com",
“partnered”: true,
“bio”: “test bio woo I’m a test user”,
“notifications”: {
“email”: true,
“push”: false
}
}
What am I doing wrong?