Welcome to WebmasterWorld Guest from 54.205.108.212

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

http user agent

want to assign

     
2:58 am on Sep 16, 2010 (gmt 0)

New User

5+ Year Member

joined:Sept 16, 2010
posts: 6
votes: 0


When I read an internet page with the file() command, the http_user_agent is reported as nothing. I want to put something there for the user_agent. I found an example here under php/3388602.htm but I can't get it to work. Not sure what should go in the Host: parameter
I'm new to this website, and having a bit of difficulty figuring it out.
2:44 am on Sept 19, 2010 (gmt 0)

New User

5+ Year Member

joined:Sept 16, 2010
posts: 6
votes: 0


It's has been several days and I haven't gotten a reply. The reason I need this is I offer a service which entails looking at things on the user site, and I need a way for them to let me through their bad bot function. Does anyone know how to make this work?
6:59 am on Sept 19, 2010 (gmt 0)

Full Member

5+ Year Member

joined:Aug 16, 2010
posts:231
votes: 13


i use curl for this:

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $fp);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,30);
curl_setopt($ch, CURLOPT_REFERER, "example.com");
curl_setopt($ch, CURLOPT_USERAGENT, "example.com (+http://www.example.com/policy/)");
$string = curl_exec($ch);
8:17 am on Sept 19, 2010 (gmt 0)

New User

5+ Year Member

joined:Sept 16, 2010
posts: 6
votes: 0


I did a quick scan of curl, but I don't know it at all.
Trying to relate this example to what I saw there has me totally confused.

The curl_exec does the read of the website?
A user agent is not normally a url, could it be something like simply "MyAgent"?
What is a referer?
What is $fp pointing to? (the curl example at php.net for reading a website uses a fopen(), do I need something like that to get the $fp?)
10:43 am on Sept 19, 2010 (gmt 0)

Full Member

5+ Year Member

joined:Aug 16, 2010
posts:231
votes: 13


yes, curl_exec reads the website.

$fp holds the url you want to read. For example $fp='http://www.google.com';

Useragent is just a string, so 'myagent' would be ok.

Just give it a try....
11:29 pm on Sept 19, 2010 (gmt 0)

New User

5+ Year Member

joined:Sept 16, 2010
posts: 6
votes: 0


Well, that worked. Thanks. I'll have to learn more about curl.

Is the REFERER necessary?
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members