-3

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

Ol Mimud
  • 9
  • 3
  • _“does not work”_ is anything but a useful problem description. Please go read [ask] and [mre], and then edit your question accordingly. – 04FS Nov 11 '19 at 13:45
  • Please show the code you have tried so far. There could be any number of pieces that would prevent it from working. Without sample code, we'd only be guessing. – David Nov 11 '19 at 13:54
  • I add the code I use with php ! – Ol Mimud Nov 11 '19 at 14:15
  • Of course I replaced ACCESS TOKEN with my personal API key, from the beginning , it does not work ! blank page – Ol Mimud Nov 11 '19 at 14:17
  • The only echo I see is if there is an error :) Try ```$result = curl_exec($ch); if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } else { echo $result; }``` – David Nov 11 '19 at 14:18
  • @David It works perfectly, thank you , you can write an answer for me to validate for people who are the same problem as me :) ! – Ol Mimud Nov 11 '19 at 14:28

1 Answers1

0

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; 
}
David
  • 344
  • 1
  • 9