PHP

以下將檢索 twitch 通道的 channel 物件並回顯響應。

  $channelsApi = 'https://api.twitch.tv/kraken/channels/';
   $channelName = 'twitch';
   $clientId = '...';
   $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);
   echo $response;