Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    424
    Thanks
    8
    Thanked 6 Times in 6 Posts

    Please help me understand this CURL_SETOPT_ARRAY() error.

    I'm getting this error:Warning: curl_setopt_array() [function.curl-setopt-array]: Array keys must be CURLOPT constants or equivalent integer values in /home/voyager1/public_html/test.php on line 74
    What I understand from the error is that all the associated array keys must be like "CURLOPT...", but I must be wrong there, because they all appear to meet that criteria.

    Here's my code
    PHP Code:
    $ch=curl_init(); // initiallize a curl session
    $url='https://www.example.com/login.htm'// define the target URI
    $options=array( CURLOPT_URL=>$url,
                    
    CURLOPT_REFERRER=>$url,
                    
    CURLOPT_USERAGENT=>'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5)',
                    
    CURLOPT_RETURNTRANSFER=>1,
                    
    CURLOPT_CONNECTTIMEOUT=>2,
                    
    CURLOPT_POST=>1,
                    
    CURLOPT_POSTFIELDS=>'org=value&login=user&pwd=password',
                    
    CURLOPT_COOKIEJAR=>'cookies.txt'
                    
    CURLOPT_COOKIEFILE=>'cookies.txt'
                    
    );
    curl_setopt_array($ch,$options); //   <-- THIS IS LINE 74 
    What am I missing ??

    ~ Mo
    Last edited by mOrloff; 01-08-2010 at 11:34 PM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    CURLOPT_REFERRER is spelled wrong. Well, wrong with PHP anyway, for whatever reason referrer has been mis-spelled as referer and has kept going all of this time. I think apache is the cause of this one.

    Edit:
    Oh yes, btw, just because it has CURLOPT in its definition doesn't mean its a part of the curl library. What they mean is that it needs to be a constant used specifically for CURL, which generally have the CURLOPT as its prefix. It could be called MYAWESOMECONNECTORCONSTANTPREFIX if you wanted it to be, as long as it matches the value for what curlopt expects. This is because PHP does not support enums (sadly).
    Last edited by Fou-Lu; 01-08-2010 at 11:42 PM.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #3
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    424
    Thanks
    8
    Thanked 6 Times in 6 Posts
    Quote Originally Posted by Fou-Lu View Post
    CURLOPT_REFERRER is spelled wrong...
    Thanks.

    Quote Originally Posted by Fou-Lu View Post
    ...
    Edit:
    Oh yes, btw, just because it has CURLOPT in its definition doesn't mean its a part of the curl library. What they mean is that it needs to be a constant used specifically for CURL...
    Thanks for the info.
    I now understand what it's saying.

    ~ Mo
    Last edited by mOrloff; 01-09-2010 at 12:26 AM.


  •  

    Posting Permissions

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