Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How To Precede A Tracking Url Onto A Url >

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 756
    Answer it

    Fellow Php Programmers,

     

    What does the following header mean (ebay.com):

    **HTTP/1.1 200 OK X-EBAY-C-REQUEST-ID: ri=N79YSYGvO9se,rci=qZJNjVUUeUF9xCaS RlogId: t6e%60cckjkb9%3Fvo%7Bccbgmijf%28vo%7B%287570577-15c59d3449c-0x129 X-Frame-Options: SAMEORIGIN X-Frame-Options: SAMEORIGIN X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block Cache-Control: private Pragma: no-cache Content-Type: text/html;charset=utf-8 Content-Language: en-US Server: ebay server X-EdgeConnect-MidMile-RTT: 172 X-EdgeConnect-Origin-MEX-Latency: 261 X-EdgeConnect-Cache-Status: 0 Date: Tue, 30 May 2017 14:47:17 GMT Transfer-Encoding: chunked Connection: keep-alive Connection: Transfer-Encoding Set-Cookie: JSESSIONID=B9699C4784AF48E8C158816A1094F78B; Path=/; HttpOnly Set-Cookie: ebay=%5Esbf%3D%23%5E;Domain=.ebay.com;Path=/ Set-Cookie: dp1=bu1p/QEBfX0BAX19AQA**5b0eb975^bl/BD5cefecf5^;Domain=.ebay.com;Expires=Thu, 30-May-2019 14:47:17 GMT;Path=/ Set-Cookie: s=CgAD4ACBZLtd1NTlkMzQ0OGMxNWMwYTg4OGQ4YzYzYTYzZmZmOGJhNjhjlJyS;Domain=.ebay.com;Path=/; HttpOnly Set-Cookie: nonsession=CgADLAAFZLYz9MQDKACBik4d1NTlkMzQ0OGMxNWMwYTg4OGQ4YzYzYTYzZmZmOGJhNjgpg9Wr;Domain=.ebay.com;Expires=Wed, 30-May-2018 14:47:17 GMT;Path=/**


    I have a feeling the header states that the visitor is the same visitor and so is this the case why I'm unable to precede the following on all links present on ebay homepage ?
    (NOTE: I'm getting cURL to fetch ebay homepage).

    http://mydomain.com/tracker.php?

    Check the following code. Run it on your xamp/wamp and then hover your mouse over the links present on ebay's homepage. Do you see all links starting with:

    http://mydomain.com/tracker.php?

    Yes, or no ? i used to see it. And so a YES from here from lastnight.
    But tonight, the answer is a NO.
    Now, I'm confused why is that ? Anything wrong with my coding ?

    [php]
    <?php
    $url = "http://www.ebay.com";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "$url");
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 5);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    $result = curl_exec($ch);
    curl_close($ch);

    /* pattern can be either 2:
    $pattern = '#http://#';
    $pattern = '/http:\/\//';
    */

    $pattern = '/http:\/\//';
    $replacement = 'http://mydomain.com/tracker.php?';

    $pattern = '/https:\/\//';
    $replacement = 'http://mydomain.com/tracker.php?';

    $pattern = '/localhost\//';
    $replacement = 'http://mydomain.com/tracker.php?';

    echo str_replace($pattern, $replacement, $result);

    ?>

    [/php]

    What I'm doing here is just replacing the "http://" with:

    http://mydomain.com/tracker.php?

    But instead of using the replace function, is there a better way to precede the following on all links found on ebay homepage ? (The technique should work on any homepage and not be dependant on ebay homepage only).
     

 1 Answer(s)

  • Hello Sir,

    I just go through your script and i found that you did mistake in below code.
    // invalid
    curl_setopt($ch, CURLOPT_URL, "$url");
    // valid code
    curl_setopt($ch, CURLOPT_URL, $url);

    If you are facing any other issue then let me know.

    Thank you
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: