PHP Curl Proxy Problem

Discussion in 'PHP' started by afimafis, Apr 9, 2012.

  1. #1
    Hello,

    hello i need use curl with proxy. but i get "undefined variable offset 1" error . here is the standart code i use.
    please help me about it

    thanks


    curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, $header); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_PROXY, $proxy); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_USERAGENT, $agent);
     
    afimafis, Apr 9, 2012 IP
  2. ROOFIS

    ROOFIS Well-Known Member

    Messages:
    1,234
    Likes Received:
    30
    Best Answers:
    5
    Trophy Points:
    120
    #2
    Hi there afimafis in future could you post code using the php 'code' icon in the editor, thanks.

    
    curl_setopt($ch, CURLOPT_URL, $url); 
    curl_setopt($ch, CURLOPT_HEADER, $header); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    curl_setopt($ch, CURLOPT_PROXY, $proxy); 
    curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); 
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 
    curl_setopt($ch, CURLOPT_REFERER, $referer); 
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    
    PHP:
    Anyway back to your scenario, could you post what line your error is referring to? I think this error pops up if you haven't assigned anything to one (or more) of your references. I count six or so up there and if any of theses are not associated to anything relative to your code then they are declared 'undefined' by php.







    ROOFIS
     
    Last edited: Apr 9, 2012
    ROOFIS, Apr 9, 2012 IP
  3. afimafis

    afimafis Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #3
    thanks for answer ROOFIS :)

    the point i am sure is page can not loaded on time.even if i use timeout as 20 sn

    i dont know what i missed

    thanks

     
    afimafis, Apr 9, 2012 IP
  4. ROOFIS

    ROOFIS Well-Known Member

    Messages:
    1,234
    Likes Received:
    30
    Best Answers:
    5
    Trophy Points:
    120
    #4
    If your script is running and returns either with an error or blank it might be your proxy connectivity as this is where a lot of problems can arise especially if connecting to public ip's.

    You could factor in error reporting (curl_error or curl_errno) into your code to troubleshoot. :)








    ROOFIS
     
    ROOFIS, Apr 9, 2012 IP
  5. afimafis

    afimafis Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    thanks i use aprox 50 public proxies.i test them and checked alive or not. after executing script, %99 of proxies can not load page
    so i belive that problem is related to proxy settings
    any idea ?

    thanks again

     
    afimafis, Apr 9, 2012 IP
  6. SocksEscort

    SocksEscort Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hello.
    Can you show variables
    $timeout and $proxy ?
     
    SocksEscort, Apr 9, 2012 IP
  7. afimafis

    afimafis Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #7
    i dont know why but curl doesnot support any type of proxies.u know any proxy standarts curl supports ?


    thanks


    curl_setopt($ch, CURLOPT_PROXY, '119.246.25.54:3128');
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50);



     
    afimafis, Apr 9, 2012 IP
  8. SocksEscort

    SocksEscort Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Try to set CURLOPT_PROXYTYPE for Socks OR Http proxy. What u use? I think you use Socks, then curl trying connect as Http proxy.
     
    SocksEscort, Apr 10, 2012 IP
  9. afimafis

    afimafis Greenhorn

    Messages:
    90
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #9
    thanks for reply but i use http one.i detect them before running them
    so what might be problem ?

    thanks


     
    afimafis, Apr 10, 2012 IP