S
S
StreetAngel2011-05-29 11:38:39
PHP
StreetAngel, 2011-05-29 11:38:39

Follow a link without passing HTTP_REFERER?

Using PHP I get a blank page, what's wrong? how to do it without using flash?

$url = 'http://www.ya.ru';<br/>
$ch = curl_init();<br/>
curl_setopt($ch, CURLOPT_URL, $url);<br/>
curl_setopt($ch, CURLOPT_REFERER, &quot;&quot;);<br/>
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<br/>
curl_setopt($ch, CURLOPT_TIMEOUT, 10);<br/>
$result = curl_exec($ch);<br/>
curl_close($ch);<br/>
echo $result;

$ch returns Resource id #45
$result empty
curl_error($ch) empty

Answer the question

In order to leave comments, you need to log in

5 answer(s)
W
webscout, 2011-05-29
@webscout

You have something wrong with cURL. A proxy may be required, or it may be blocked.
Your example works for me and produces a Yandex page.
And here the flush is not finished at all.

M
MrCrock, 2011-05-29
@MrCrock

First, look at what happens during the request: And here is what your script returns: I.e. in other words, it follows a redirect. Here is the working code:
cmd> GET /download/2402254/DJ_GROOVE_feat_LOC_DOG_PHIL_SHABIN_NEMINUEMA.mp3 HTTP/1.0
cmd> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
cmd> User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; DigExt)
cmd> Host: pdj.ru
cmd>
hdr> HTTP/1.1 302 Yap
hdr> Server: nginx
hdr> Date: Sun, 29 May 2011 10:04:06 GMT
hdr> Content-Type: application/octet-stream
hdr> Connection: close
hdr> Cache-Control: max-age=0
hdr> Pragma: no-cache
hdr> Location: ams-teardrop1.cdn.promodeejay.net/3G3s4vin3Z2f4Mgl3ZEn4vkf3v2ncvT-3v2s3vym4egS3GCf3ZiQ4egl36yf3egj36Ej36Ej36yj4vij4Gkj3v2s3vym458S3GCf3ZiQ4UQDk64-t6T-3Ighi12ZOrB=/DJ_GROOVE_feat_LOC_DOG_PHIL_SHABIN_NEMINUEMA.mp3
cmd> GET /3G3s4vin3Z2f4Mgl3ZEn4vkf3v2ncvT-3v2s3vym4egS3GCf3ZiQ4egl36yf3egj36Ej36Ej36yj4vij4Gkj3v2s3vym458S3GCf3ZiQ4UQDk64-t6T-3Ighi12ZOrB=/DJ_GROOVE_feat_LOC_DOG_PHIL_SHABIN_NEMINUEMA.mp3 HTTP/1.0
cmd> Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
cmd> User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; DigExt)
cmd> Host: ams-teardrop1.cdn.promodeejay.net
cmd>
hdr> HTTP/1.1 200 OK
hdr> Server: nginx
hdr> Date: Sun, 29 May 2011 10:04:21 GMT
hdr> Content-Type: audio/mpeg
hdr> Content-Length: 11121893
hdr> Last-Modified: Sun, 22 May 2011 04:39:04 GMT
hdr> Connection: close
hdr> Pragma: no-cache
hdr> Cache-Control: max-age=0
hdr> Content-Disposition: attachment
hdr> Accept-Ranges: bytes
RequestDone Error = 0
StatusCode = 200
=======================

HTTP/1.1 302 Yap
Server: nginx
Date: Sun, 29 May 2011 10:08:59 GMT
Content-Type: application/octet-stream
Transfer-Encoding: chunked
Connection: keep-alive
Cache-Control: max-age=0
Pragma: no-cache
Location: msk-bodymovin1.cdn.promodeejay.net/3G3s4vin3Zkf3Mgl3ZEn4vkf4G2ScvT-3v2s3vym4egS3GCf363Q4hgl36yf3egj36Ej36Ej36yj4vij4Gkj3v2s3vym458S3GCf363Q4SQDk64-3ZT-3IgmtGHb4Zk=/DJ_GROOVE_feat_LOC_DOG_PHIL_SHABIN_NEMINUEMA.mp3

$url = 'http://pdj.ru/download/2402254/DJ_GROOVE_feat_LOC_DOG_PHIL_SHABIN_NEMINUEMA.mp3';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_REFERER, "");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 360);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$result = curl_exec($ch);
curl_close($ch);
echo $result;

S
StreetAngel, 2011-05-29
@StreetAngel

Well, for example, such a link, i.e. if you go through it, then we get to the download page, and if you drive it into the address bar, then there will be an mp3 jump, but how to make the jump start immediately when you go through it?
http://pdj.ru/download/2402254/DJ_GROOVE_feat_LOC_DOG_PHIL_SHABIN_NEMINUEMA.mp3

M
MrCrock, 2011-05-29
@MrCrock

Parse the file addresses from the header, save it all to a text file in the format string=URL and export it to the Download Master, which will download this entire list. If done quickly, temporary links will still be alive.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question