how to use cURL API, from a video host 'MyStream.to'
in php!
API DOCUMENTATION FOR MyStream.to
1 This is the code that the documentation shows me :
curl "https://api.mystream.to/v1/files/:page" -H "Authorization: ACCESS_TOKEN" -D
2 I also tried (https://incarnate.github.io/curl-to-php/) it does not work "for me" :
(of course I replaced ACCESS TOKEN with my personal API key.)
<?php
// Generated by curl-to-PHP: http://incarnate.github.io/curl-to-php/
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.mystream.to/v1/account-
information');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$headers = array();
$headers[] = 'Authorization: ACCESS_TOKEN';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
?>
nothing is displayed with this php code
Fortunately, there are no bugs here :)
However the only echo()
statement I see is if there is an error. Otherwise no output is made!
Try:
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
} else {
echo $result;
}