1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Change User Agent

Discussion in 'PHP & Perl' started by darkstar69, Jul 6, 2012.

  1. darkstar69

    darkstar69 Jr. VIP Jr. VIP

    Joined:
    Nov 15, 2008
    Messages:
    806
    Likes Received:
    880
    Occupation:
    Big Boss
    Location:
    On The Dark Side
    Hello,
    This time I´d like to know if there is a way to change the user agent.
    By now I only found

    Code:
    ini_set("user_agent","Your User Agent String");
    And then access the websites per
    Code:
    $data = file_get_contents("http://whateverwebsite.com");
    echo "$data";
    But then the problem is that for every user the IP of the server where my website is stored is shown.
    So my question is if there is a way to change the user agent and still keep the original users IP address.
     
  2. DevSwift

    DevSwift Newbie

    Joined:
    Jul 5, 2012
    Messages:
    6
    Likes Received:
    1
    Location:
    Raleigh, NC (USA)
    Home Page:
    You can use cURL to grab the URL, then troggle the CURLOPT_USERAGENT option via curl_setopt function.