Hi.
I would like to get json data of clips. Response:
{“error”:“Not Found”,“status”:404,“message”:“Clip does not exist”}
Another data like channel, streams is OK.
Hi.
I would like to get json data of clips. Response:
{“error”:“Not Found”,“status”:404,“message”:“Clip does not exist”}
Another data like channel, streams is OK.
Are you requesting from API v4 like required for clips?
Example request:
GET /kraken/clips/streamcorner/BraveWallabyMikeHogu HTTP/1.1
Accept: application/vnd.twitchtv.v4+json
Host: api.twitch.tv
Client-Id: d12jokwzby5m9e82gouqsjogd66inh
HTTP/1.1 200 OK
Date: Sat, 18 Feb 2017 13:40:33 GMT
Content-Type: application/json
Content-Length: 1525
Connection: keep-alive
Server: nginx
Access-Control-Allow-Headers: Accept, Authorization, Client-Id, Twitch-Api-Token, X-Forwarded-Proto, X-Requested-With, X-Csrf-Token, Content-Type
Access-Control-Allow-Methods: GET, POST, PUT, DELETE
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 0
Twitch-Trace-Id: c900eff715f7a60b1cf8f3364c05601e
Front-End-Https: on
{"id":"streamcorner/BraveWallabyMikeHogu","url":"https://clips.twitch.tv/streamcorner/BraveWallabyMikeHogu?tt_medium=clips_api\u0026tt_content=url","embed_url":"https://clips.twitch.tv/embed?clip=streamcorner/BraveWallabyMikeHogu\u0026tt_medium=clips_api\u0026tt_content=embed","embed_html":"\u003ciframe src='https://clips.twitch.tv/embed?clip=streamcorner/BraveWallabyMikeHogu\u0026tt_medium=clips_api\u0026tt_content=embed' width='640' height='360' frameborder='0' scrolling='no' allowfullscreen='true'\u003e\u003c/iframe\u003e","broadcaster":{"id":"81300244","name":"streamcorner","display_name":"StreamCorner","channel_url":"https://www.twitch.tv/streamcorner","logo":"https://static-cdn.jtvnw.net/jtv_user_pictures/streamcorner-profile_image-a26d8edacc37c672-300x300.jpeg"},"curator":{"id":"17089325","name":"3v","display_name":"3v","channel_url":"https://www.twitch.tv/3v","logo":"https://static-cdn.jtvnw.net/jtv_user_pictures/3v-profile_image-aaa5f1b8946fa6b9-300x300.png"},"vod":{"id":"119593832","url":"https://www.twitch.tv/videos/119593832?t=14h45m17s"},"game":"Overwatch","title":"IS Striimicorner Assembly Winter 2017 @ Messukeskus, Helsinki, Finland","views":9,"duration":44,"created_at":"2017-02-05T17:26:53Z","thumbnails":{"medium":"https://clips-media-assets.twitch.tv/24428270176-offset-53074-44-preview-480x272.jpg","small":"https://clips-media-assets.twitch.tv/24428270176-offset-53074-44-preview-260x147.jpg","tiny":"https://clips-media-assets.twitch.tv/24428270176-offset-53074-44-preview-86x45.jpg"}}
I use PHP + CURL:
public function getTwitch($url){
$channelsApi = $url;
$channelName = 'twitch';
$clientId = 'xxx';
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array(
'Client-ID: ' . $clientId,
'Accept: application/vnd.twitchtv.v4+json'
),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $channelsApi . $channelName
));
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
That gets the channel(?) and looks fine… (although you should use v4 only for clips and v5 for everything else, v3 is fine but should be avoided for new development)
I changed to v5 and is the same problem - error 404. Clips is exist, but message is:
Clip does not exist
CURL url look like:
https://api.twitch.tv/kraken/clips/playhearthstone/HelpfulYakBigBrother
Your code is appending twitch
to the end of $url
My 3 function to get data:
public function getTwitch($url){
$channelsApi = $url;
$channelName = 'twitch';
$clientId = 'xxx';
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_HTTPHEADER => array(
'Client-ID: ' . $clientId,
'Accept: application/vnd.twitchtv.v4+json'
),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $channelsApi . $channelName
));
$response = curl_exec($ch);
curl_close($ch);
return $response;
}
I choose type of data:
public function getApiUri($type) {
$apiUrl = "https://api.twitch.tv/kraken";
$apiCalls = array(
"streams" => $apiUrl."/streams/",
"search" => $apiUrl."/search/",
"channel" => $apiUrl."/channels/",
"user" => $apiUrl."/user/",
"teams" => $apiUrl."/teams/",
"clips" => $apiUrl."/clips/",
);
return $apiCalls[$type];
}
And I try to get Clip’s data:
public function GetClip($url) {
$s = $this->getTwitch($this->getApiUri("clips").$url);
//$json = json_decode($s, true);
return $s;
}
return $s
is temporary
And… for example:
$clip->GetClip(‘playhearthstone/HelpfulYakBigBrother’);
CURLOPT_URL => $channelsApi . $channelName
makes it https://api.twitch.tv/kraken/clips/playhearthstone/HelpfulYakBigBrothertwitch
, no?
Yeah, thank you! It’s works!
Stupid mistake from me
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.