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;