473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Sending a User-Agent header

228 100+
i just try it it works for bbc site
your server might not allow you openning anything out of your root folder
especialy if your site is hosted
[php]
$a = file("http://www.bbc.co.uk");
$a = implode($a);

echo htmlentities($a);

[/php]
LOL they recognize browser and sent me WAP like formated page

any one know how to pretend tha PHP is IE?

regards
jx2
Aug 23 '07 #1
4 10325
pbmods
5,821 Expert 4TB
Heya, JX2.

To do that, you'll need to either create an HTTP stream context or else use cURL so that you can set the User-Agent header.
Aug 23 '07 #2
jx2
228 100+
Heya, JX2.

To do that, you'll need to either create an HTTP stream context or else use cURL so that you can set the User-Agent header.
sorry to ask you - have you got simply handy example ? you know something to start with...
thx

wow something moved i didnt know i started new post :-)
Aug 23 '07 #3
pbmods
5,821 Expert 4TB
Heya, JX2.

I went ahead and split these posts into their own thread so as to avoid hijacking NewLearner's thread.

Here's a basic example:
Expand|Select|Wrap|Line Numbers
  1. $context = stream_context_create(array('http' => array(
  2.     'method'    => 'get',
  3.     'header'    => 'User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/522.11.1 (KHTML, like Gecko) Version/3.0.3 Safari/522.12.1'
  4. )));
  5.  
  6. $data = file_get_contents($url, $context);
  7.  
This code will send the User-Agent header with the HTTP GET request.

For more information, check out this document.
Aug 23 '07 #4
jx2
228 100+
Expand|Select|Wrap|Line Numbers
  1. $context = stream_context_create(array('http' => array(
  2.     'method'    => 'get',
  3.     'header'    => 'User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/522.11.1 (KHTML, like Gecko) Version/3.0.3 Safari/522.12.1'
  4. )));
  5.  
  6. $fp = fopen($url,false,$context);
  7. fpasthrou($fp);
  8.  
as usually you are the man!!
Aug 23 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Cyrus D. | last post by:
Hi guys, I want to do something simple, here is the code: <?php if($ageCheck) // goto mainpage.html else // goto under21.html
1
by: James Hu | last post by:
Hi, There are 2 wxPython application, A and B and need to exchange msg. Sending WM_CLOSE, wxEVT_MOUSEWHEEL to B is OK, and sending user message like 1225 from A to B is also OK. But B didn't...
13
by: joe215 | last post by:
I want my users to send emails from a Windows app that I am developing in Visual Basic.NET 2003. I found a good example of sending email to a SMTP server using the SmtpMail class. However, using...
0
by: Mrozik | last post by:
Hi! I have my own class "mtxApplicationException" bulid like shown in "MS Error Handling Block". When i use it in windows application everything works fine. But when I throw this exception in...
1
by: hsifelbmur | last post by:
Our software launches a variety of applications and prints documents using shellExecute and the printto verb. Occasionally, a program will get stuck and will not be able to print, requiring user...
7
by: Lau | last post by:
I need to send 1000 emails from an asp.net website. Normally I would use System.Web.Mail.MailMessage() to send thru an SMTP server. But the large amount of emails results in a timeout. My server...
3
by: Michael Glaesemann | last post by:
Hello all, Recently I've been thinking about different methods of managing users that log into a PostgreSQL-backed application. The users I'm thinking of are not necessarily DBAs: they're...
2
by: frank1730 | last post by:
Hi all, I have created a program on vb 2005 where the user can input their information into 2 textboxes and then submit the information by clicking on a button under the text boxes. The idea of this...
4
by: suganya | last post by:
Hi By getting the email id from txtEmailId, I have to send the user name & password to that particular email id. For that on button click event I have given the coding as Protected Sub...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.