0

I had been using PHP curl to get the contents of a file, hosted on a different server. The file can easily be opened on a browser like Chrome etc., but with cURL, it always returns a blank page.

The file is hosted on an Nginx server and even miniproxy.php fails to get contents. Instead, it returns 406 not acceptable. I tried using the HTTP spy extension to monitor the request sent and found the following header:

Upgrade-Insecure-Requests:1 I tried sending the same header along With other headers, but in vain. Still, I couldn't rectify my mistake. On the Internet, I found the zalmos proxy which was able to get the contents of the file. The curl code I wrote is attached below.

$url = "http://smumcdnems01.cdnsrv.jio.com/jiotv.live.cdn.jio.com/" . $ch . "/" . $ch . "_" . $q  . ".m3u8" . $tok;
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);

$headers = array(
   "User-Agent: agent",
   "lbcookie: 300",
   "devicetype: 1",
   "os: android",
   "appkey: 1111111",
   "deviceId: device id",
   "uniqueId: unique id",
   "ssotoken: any token",
   "Upgrade-Insecure-Requests: 1",
   "Host: example.com",
   "Connection: keep-alive",
   "X-Chrome-offline: persist=0 reason=reload",
   "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
   "Accept-Encoding: gzip, deflate, sdch",
   "Accept-Language: en-GB,en-US;q=0.9,en;q=0.8",
   "subscriberId: any id",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
//for debug only!
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

$resp = curl_exec($curl);
curl_close($curl);
echo $url;
echo $resp;

I believe that any part is missing in my code which is posing a problem. How can this be rectified?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
  • Have you tried debugging curl? https://stackoverflow.com/questions/3757071/php-debugging-curl – FJJ Jan 27 '21 at 11:28
  • Till now i haven't , thanks for advice , will try to do it and get error but on checking it with capture apps , it give "200 ok" . Maybe thus would lead me to solution – PIYUSH ADLAKHA Jan 27 '21 at 13:21

2 Answers2

0

Check your URL. Curl must give you the response. If it's hit the target URL, either the target URL is not responding to anything when sending the request.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Muhammad Nouman
  • 33
  • 2
  • 10
0

You may be trying to access a websocket. Try to simulate with Postman to get more information.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
FJJ
  • 3
  • 4