JSON + PHP - Cant get a valid download/streaming link

233 views Asked by At

I wanna get a functional download/videostreaming link, i'm trying this through Openload and pCloud API, but I always getting error when I put my script in anywhere outside my localhost.

My pCloud code is:

 <?


ini_set('display_errors','0');


echo '<form method="POST" enctype="multipart/form-data" id="add-row-form" action="">';
echo "<input type='text' value='XZ1Ix57ZIVJU5FGmV8bkvWwukuJ0JBkIKJzX' placeholder='ID da Série' name='tvshowid'></input>";
echo "<button name='ok' type='submit'>Tudo certo</button>";
echo '</form>';


$query = $_POST['tvshowid'];
$lang = $_POST['lang'];




if(isset($_POST['ok'])) {


$postdata = file_get_contents("https://api.pcloud.com/getpublinkdownload?code=". $query);
$request = json_decode($postdata);





print_r($request);


$theData = $request;
 $host = $theData->hosts[rand(0,1)];
 $path = $theData->path;
 $vlink = 'https://'.$host. $path;

echo '<div>';
echo '<video width="30%" height="auto" controls autoplay>
  <source src="'.$vlink.'" type="video/mp4">
</video>';
echo "</div>";
}
?>

Preview

Always when i try to generate a link, it says "This link was generated for another IP address. Try previous step again." The question is: How can I get data from a JSON through my user's IP or server adrres and not by my server address (as has been happening), so that the video link is valid?

0

There are 0 answers