SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: cURL

  1. #1
    Non-Member pbkill's Avatar
    Join Date
    Jan 2006
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cURL

    Im trying to add a new feature to my site but I cant seem to get it right.

    Here is my current code.
    Code:
    // create a new curl resource
    $ch = curl_init();
    
    // set URL and other appropriate options
    
    curl_setopt($ch, CURLOPT_URL, "$nl2");
    
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION);
    
    $curl = curl_exec($ch);
    It cURLS a link that redirects from my site to the end site. It is for tracking my affiliates.

    What I want is to recive the end link which I thought the above code but isted it ouputs this:

    Code:
    The URL has moved here
    And hear is the URL i want......

    Any ideas? Thanks!

  2. #2
    SitePoint Zealot krt's Avatar
    Join Date
    Sep 2005
    Location
    Australia
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well you have to parse the contents, get the URL you want and use cURL to access that page.

  3. #3
    SitePoint Guru toasti's Avatar
    Join Date
    Feb 2004
    Location
    Grahamstown
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try:
    Code:
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
    you can also do:

    Code:
    $result = curl_exec($ch); // run the whole process
    print_r(curl_getinfo($ch)); 
    echo "\n\ncURL error number:" .curl_errno($ch); 
    echo "\n\ncURL error:" . curl_error($ch); 
    curl_close($ch);
    to get some debugging info.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •