Change browser name on file_get_contents or cURL request

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
LuckyShot
Forum Newbie
Posts: 13
Joined: Thu Sep 25, 2008 5:02 pm
Location: Barcelona

Change browser name on file_get_contents or cURL request

Post by LuckyShot »

Good day,

I am using file_get_contents() function to get external content from an external website (...and format it in XML, etc.).

I was wondering if there is any way in PHP to modify the browser information requesting the external page.
So that when executing a file_get_contents I could customize it to get the content as if it was seen through
whatever browser I decide (Firefox, Explorer, Safari...).
It's not about detecting the browser type but changing the browser type when requesting the page.

Is that feasible in PHP5 ...or 6?
I have read the PHP manual and can't find any information regarding this. Not even a relevant result by Googling it.
Maybe through cURL instead of file_get_contents?

Please let me know if you need any more details, examples or explanation.

Thank you and best regards,

LuckyShot
phppucci
Forum Newbie
Posts: 17
Joined: Fri Oct 03, 2008 2:27 pm

Re: Change browser name on file_get_contents or cURL request

Post by phppucci »

use curl. there you can setup everything you need.
Post Reply