카테고리 없음

twitch api 연동

[czar] 2016. 11. 14. 11:20
https://www.twitch.tv/settings/connections
OAuth 연동
개발자 커스텀 애플리케이션 - 

애플리케이션 등록
jQuery
$.ajax({
type: 'GET',
url: 'https://api.twitch.tv/kraken/channels/twitch',
headers: {
'Client-ID': 'axjhfp777tflhy0yjb5sftsil'
},
success: function(data) {
console.log(data);
}
});
cURL
curl -i -H 'Accept: application/vnd.twitchtv.v3+json'\
-H 'Client-ID: axjhfp777tflhy0yjb5sftsil'\
'https://api.twitch.tv/kraken/channels/twitch'
PHP
<?php
$channelsApi = 'https://api.twitch.tv/kraken/channels/';
$channelName = 'twitch';
$clientId = 'axjhfp777tflhy0yjb5sftsil';
$ch = curl_init();

curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array(
'Client-ID: ' . $clientId
),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $channelsApi . $channelName
));

$response = curl_exec($ch);
curl_close($ch);
?>