<?php
require "site.class.php"
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers:*");
$app = new site('');
$mode = $_POST['submode'];
$client_id = <client id>;
$lease_seconds = 24*60*60;
$postData = array(
'hub.mode' => $mode,
'hub.topic' => "https://api.twitch.tv/helix/users/follows?first=1&to_id=23161357",
'hub.callback' => '<website>/PHP/webHookHandle.php',
'hub.lease_seconds' => $lease_seconds,
);
$dataEncode = json_encode($postData);
$httpHeader = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($dataEncode),
'Client-ID: ' . $client_id
);
$app->bufferPost("https://api.twitch.tv/helix/webhooks/hub", $dataEncode, $httpHeader);
?>
public function bufferPost($link, $postField, $httpHeader) {
curl_setopt($this->curl, CURLOPT_VERBOSE,true);
curl_setopt($this->curl, CURLOPT_URL, $link);
curl_setopt($this->curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->curl, CURLOPT_USERAGENT, $this->userAgent);
curl_setopt($this->curl, CURLOPT_POST, true);
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $postField);
curl_setopt($this->curl, CURLOPT_HTTPHEADER, $httpHeader);
//turn off HTTPs errors
curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false);
//where cookies are saved if cookie exists
if ($this->cookieFile) {
curl_setopt($this->curl, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($this->curl, CURLOPT_COOKIEJAR, $this->cookieFile);
}
curl_setopt($this->curl, CURLOPT_COOKIE, $this->cookie);
curl_setopt($this->curl, CURLOPT_REFERER, $this->referer);
$this->bufferPage = curl_exec($this->curl);
$httpCode = curl_getinfo($this->curl , CURLINFO_HTTP_CODE);
}
That should cover everything for the subscription part.