By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,442 Members | 1,302 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,442 IT Pros & Developers. It's quick & easy.

Can php emulate internet explorer browser requests ?

P: n/a
I'm looking to post data (GET) to a site using a php script - commands
like fopen() file_content_gets won't retrieve the data. I assume this
is because the server is expecting the request to come from a browser.

What do I need to do to make sure the request appears to be coming
form a browser, and what would be the best way of posting the data ?
cURL pear fsockopen ? Do I need to recreate the headers that are sent
via IE6 to spoof the server ? Also I think the site may use browser
session cookies and the login page is via https.

If it's too hard or impossible for php I guess I'll have to port my
code over to VB .Net as I assume that program uses the IE libraries
anyway ?
Jul 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Captain wrote:
I'm looking to post data (GET) to a site using a php script - commands
like fopen() file_content_gets won't retrieve the data. I assume this
is because the server is expecting the request to come from a browser.


Tricky.

You should get *something*. The PHP installation may be cobbled if it's not
on a dedicated machine.

The standard system can't cope with cookies, redirects and javascript.
Snoopy (available at sourceforge) can do a lot (but IIRC not javascript)

HTH

C.
Jul 17 '05 #2

P: n/a
Captain wrote:
I'm looking to post data (GET) to a site using a php script - commands
like fopen() file_content_gets won't retrieve the data. I assume this
is because the server is expecting the request to come from a browser.

What do I need to do to make sure the request appears to be coming
form a browser, and what would be the best way of posting the data ?
cURL pear fsockopen ? Do I need to recreate the headers that are sent
via IE6 to spoof the server ? Also I think the site may use browser
session cookies and the login page is via https.

If it's too hard or impossible for php I guess I'll have to port my
code over to VB .Net as I assume that program uses the IE libraries
anyway ?


http://pear.php.net/manual/en/packag...ttp-client.php
Jul 17 '05 #3

P: n/a
<?php
ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

echo file_get_contents('http://google.com/');

?>

it's that easy.

On 26.04.2005 14:38, Captain wrote:
I'm looking to post data (GET) to a site using a php script - commands
like fopen() file_content_gets won't retrieve the data. I assume this
is because the server is expecting the request to come from a browser.

What do I need to do to make sure the request appears to be coming
form a browser, and what would be the best way of posting the data ?
cURL pear fsockopen ? Do I need to recreate the headers that are sent
via IE6 to spoof the server ? Also I think the site may use browser
session cookies and the login page is via https.

If it's too hard or impossible for php I guess I'll have to port my
code over to VB .Net as I assume that program uses the IE libraries
anyway ?

Jul 17 '05 #4

P: n/a
If only it was that easy Hannes :)

The is is the url of one the the pages

http://www.betfair.com/betting/BetsM...do?=1062510579

Compare the response from a browser requesting that page and the
file_contents_gets or fopen requests. I think I'll have to check out
the pear scripts as none of the curl ones I tried seemed to work
either

Hannes Dorbath <li***@theendofthetunnel.de> wrote in message news:<42***********************@news.disputo.net>. ..
<?php
ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

echo file_get_contents('http://google.com/');

?>

it's that easy.

Jul 17 '05 #5

P: n/a
that page doesn't work for me even in IE. there is some timeout msg in
the js..

however, it's easy anyway. grab

http://www.blunck.info/iehttpheaders.html

surf that page, take the requerst header, use

fwrite(fsockopen('that.strange.host', 80), $headers);

in case of https use fsockopen('ssl://that.strange.host', 443);

done.

On 27.04.2005 10:43, Captain wrote:
If only it was that easy Hannes :)

The is is the url of one the the pages

http://www.betfair.com/betting/BetsM...do?=1062510579

Compare the response from a browser requesting that page and the
file_contents_gets or fopen requests. I think I'll have to check out
the pear scripts as none of the curl ones I tried seemed to work
either

Hannes Dorbath <li***@theendofthetunnel.de> wrote in message news:<42***********************@news.disputo.net>. ..
<?php
ini_set('user_agent', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)');

echo file_get_contents('http://google.com/');

?>

it's that easy.

Jul 17 '05 #6

P: n/a
NC
Captain wrote:

I'm looking to post data (GET) to a site using a php script -
commands like fopen() file_content_gets won't retrieve the data.
I assume this is because the server is expecting the request
to come from a browser.
Assumptions won't do. Unless you know what the problem is, you
can't fix it. You need to look at HTTP headers that are being
exchanged between the browser and the server. It is possible
the server sends cookies and expects the client to have them.
What do I need to do to make sure the request appears to be
coming form a browser, and what would be the best way of
posting the data ? cURL pear fsockopen ?
I have worked successfully with both fsockopen() and cURL.
If it's too hard or impossible for php I guess I'll have to
port my code over to VB .Net as I assume that program uses
the IE libraries anyway ?


Since at this point you don't know what your problem is,
switching to another programming language is premature.

Cheers,
NC

Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.