curl-and-php
Re: error when using curl
Date: Tue, 18 Mar 2008 19:04:36 -0400
Here is the code I have
curl_setopt($ch, CURLOPT_URL, 'http://www.google.ca/');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$this->returnurl = curl_exec($ch);
echo curl_error($ch) . ' curl_exec';
echo curl_errno($ch) . ' curl_exec';
curl_close($ch);
The first echo statements returns "Failed to open/read local data from file/application" the second one returns 26
-- Akin
----------------------------------------
> From: curl-and-php-request_at_cool.haxx.se
> Subject: curl-and-php Digest, Vol 31, Issue 10
> To: curl-and-php_at_cool.haxx.se
> Date: Tue, 18 Mar 2008 23:14:54 +0100
>
> Send curl-and-php mailing list submissions to
> curl-and-php_at_cool.haxx.se
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
> or, via email, send a message with subject or body 'help' to
> curl-and-php-request_at_cool.haxx.se
>
> You can reach the person managing the list at
> curl-and-php-owner_at_cool.haxx.se
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of curl-and-php digest..."
>
>
> Today's Topics:
>
> 1. Re: Retrieving the authenticated username:password from
> server with PHP (Christopher Vrooman)
> 2. error when using curl (Akin D)
> 3. Re: error when using curl (Michael Horowitz)
> 4. curl and xml problem (Michael Horowitz)
> 5. Re: curl and xml problem (Daniel Stenberg)
> 6. Re: curl and xml problem (Michael Horowitz)
> 7. Re: curl and xml problem (Daniel Stenberg)
> 8. Re: curl and xml problem (Michael Horowitz)
> 9. Re: curl and xml problem (Daniel Stenberg)
> 10. Re: curl and xml problem (Michael Horowitz)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 18 Mar 2008 09:03:00 -0300
> From: "Christopher Vrooman"
> Subject: Re: Retrieving the authenticated username:password from
> server with PHP
> To: curl-and-php_at_cool.haxx.se
> Message-ID:
>
> Content-Type: text/plain; charset=UTF-8
>
> simon wrote:
>> Christopher Vrooman wrote:
>> > I would assume they would show up in $_SERVER['PHP_AUTH_USER'] &
>> > $_SERVER['PHP_AUTH_PW'], but those two variables have never, ever
>> > appeared for me.
>> >
>> I can confirm that these variables do indeed work, and are set in PHP
>> when a user is authenticated by simple http auth - I was working with a
>> project using these yesterday.
>>
>
> Simon, thanks for the quick reply.
>
> Maybe I wasn't clear about what I want to do.
>
> I'm trying to create a PHP5 REST based chat client a l? Twitter (only
> not with millions of users). So I want to be able to authenticate a
> user who logs into my website "normally" i.e. not with a basic realm
> dialogue box, rather just a vanilla login, because the chat will be an
> "extra" for another site, so the login to the chat should be
> secondary, perhaps with a different username/pw I'll pull from a
> database (so no Basic Auth).
>
> So are you saying that if I use:
>
> curl_setopt($curl_handle, CURLOPT_USERPWD, "username:password");
>
> Then that should *automatically* create the $_SERVER[PHP_AUTH_*] entries?
>
> If so, I'm in trouble because I tried every curl_setopt($ch,
> CURLOPT_HTTPAUTH, CURLAUTH_ANY); setting I could find, and the elusive
> PHP_AUTH_* never appeared in $GLOBALS.
>
> What is more... a Twitter API class I found by Nick Beam, doesn't even
> set CURLOPT_HTTPAUTH at all, yet it works with their server :(
>
> So, maybe if the problem is my server, you could give me a hint as to
> how to determine what my server needs me to specify to get things
> working?
>
> Sincerely,
> Christopher.
>
> ------------------------------
>
> Message: 2
> Date: Tue, 18 Mar 2008 09:32:26 -0400
> From: Akin D
> Subject: error when using curl
> To:
> Message-ID:
> Content-Type: text/plain; charset="iso-8859-1"
>
>
> I'm getting the following error:
> Failed to open/read local data from file/application
>
> What does this mean exactly? What is curl trying to open/read?
>
> Thanks
>
>
>
> _________________________________________________________________
> At a loss for words? Find them by playing Seekadoo! Play now!
> http://g.msn.ca/ca55/208
>
> ------------------------------
>
> Message: 3
> Date: Tue, 18 Mar 2008 09:44:47 -0400
> From: Michael Horowitz
> Subject: Re: error when using curl
> To: curl with PHP
> Message-ID:
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Are you reading information from a file.
>
> Post your code. It will be easier to see what you are doing.
>
> Michael Horowitz
> Your Computer Consultant
> http://yourcomputerconsultant.com
> 561-394-9079
>
>
>
> Akin D wrote:
>> I'm getting the following error:
>> Failed to open/read local data from file/application
>>
>> What does this mean exactly? What is curl trying to open/read?
>>
>> Thanks
>>
>>
>>
>> _________________________________________________________________
>> At a loss for words? Find them by playing Seekadoo! Play now!
>> http://g.msn.ca/ca55/208
>> _______________________________________________
>> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>>
>>
>
>
> ------------------------------
>
> Message: 4
> Date: Tue, 18 Mar 2008 10:35:52 -0400
> From: Michael Horowitz
> Subject: curl and xml problem
> To: curl with PHP
> Message-ID:
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Here is what is being received by the server with my problem of sending
> xml using curl.
>
> array(1) {
> ["
> string(972) "\"1.0\"?>
>
> LoginAccountPassword=\"Password\">
>
>
>
> BorrowerID=\"BorRec0001\" CreditReportRequestActionType=\"Submit\"
> CreditReportType=\"Consumer\" CreditRequestType=\"Individual\">
> _ExperianIndicator=\"Y\" _TransUnionIndicator=\"N\"/>
>
>
> _MiddleName=\"\" _LastName=\"Consumer\" _SSN=\"376988419\">
> _City=\"Burbank\" _State=\"Ca\" _PostalCode=\"20906\"/>
>
>
>
>
>
>
> "
> }
>
>
> I think it needs to come in as a string and not an array. Am I correct
> in thinking that?
>
> Thanks for any help people can give me
>
> --
> Michael Horowitz
> Your Computer Consultant
> http://yourcomputerconsultant.com
> 561-394-9079
>
>
>
> ------------------------------
>
> Message: 5
> Date: Tue, 18 Mar 2008 20:44:40 +0100 (CET)
> From: Daniel Stenberg
> Subject: Re: curl and xml problem
> To: michael_at_yourcomputerconsultant.com, curl with PHP
>
> Message-ID:
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Tue, 18 Mar 2008, Michael Horowitz wrote:
>
>> I think it needs to come in as a string and not an array. Am I correct in
>> thinking that?
>>
>> Thanks for any help people can give me
>
> Did you pass a string or a hash array to CURLOPT_POSTFIELDS when you send the
> POST?
>
> --
> Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
>
>
> ------------------------------
>
> Message: 6
> Date: Tue, 18 Mar 2008 15:56:41 -0400
> From: Michael Horowitz
> Subject: Re: curl and xml problem
> To: Daniel Stenberg
> Cc: curl with PHP
> Message-ID:
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> Here is the code I am using. I am sending a string. I've dont this by
> just passign the string created by the createxml.php and by doing the
> asXML() version.
>
> I've gone through several iterations of this
>
> Require 'createxml.php';
> $Result = simplexml_load_string($result);
> $xmlResult= $Result->asXML();
> $ch= curl_init();
> curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
> curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Accept: text/xml"));
> curl_setopt($ch, CURLOPT_URL, "http://testurl.com");
> curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlResult);
> curl_setopt($ch, CURLOPT_POST,1);
> curl_exec($ch);
>
> The xml shows up after it is posted as
> array(1) {
> ["
> string(972) "\"1.0\"?>
>
> LoginAccountPassword=\"Password\">
>
>
>
> BorrowerID=\"BorRec0001\" CreditReportRequestActionType=\"Submit\"
> CreditReportType=\"Consumer\" CreditRequestType=\"Individual\">
> _ExperianIndicator=\"Y\" _TransUnionIndicator=\"N\"/>
>
>
> _MiddleName=\"\" _LastName=\"Consumer\" _SSN=\"376988419\">
> _City=\"Burbank\" _State=\"Ca\" _PostalCode=\"20906\"/>
>
>
>
>
>
>
> "
> }
>
>
> the \ that are created seen before the " are created as escape
> characters by the post.
>
> When talking to people about it I've had some mention something about
> passing it as a dom object. I use dom to create the xml (see below) and
> even tried pass $dom but that didn't work or make sense to me. Another
> suggestion was to pair it up with a variable to have a standard key
> -->value post relationship. That didn't work either. And the external
> server I am sending it to wouldn't know what variable name I would
> choose so I don't think that is the right suggestion either.
>
> Thanks for any help. I'm sure I am missing something simple here about
> how xml is supposed to be posted. I'm not sure of even the different
> options.
> Links with good reading are appreciated to fully understand what I am doing.
>
> $dom = new DOMDocument('1.0');
> //create root element and append it to the document
> $REQUEST_GROUP = $dom->appendChild($dom->createElement('REQUEST_GROUP'));
> $REQUEST_GROUP->setAttribute('MISMOVersionID','2.1');
>
> $REQUEST=$REQUEST_GROUP->appendChild($dom->createElement('REQUEST'));
> $REQUEST->setAttribute('LoginAccountIdentifier','testuser');
> $REQUEST->setAttribute('LoginAccountPassword','Password');
>
> $KEY=$REQUEST->appendChild($dom->createElement('KEY'));
> $KEY->setAttribute('_Name','MemberID');
> $KEY->setAttribute('_Value','100');
>
> $REQUEST_DATA=$REQUEST->appendChild($dom->createElement('REQUEST_DATA'));
> $CREDIT_REQUEST=$REQUEST_DATA->appendChild($dom->createElement('CREDIT_REQUEST'));
> $CREDIT_REQUEST->setAttribute('MISMOVersionID','2.1');
>
> $CREDIT_REQUEST_DATA=$CREDIT_REQUEST->appendChild($dom->createElement('CREDIT_REQUEST_DATA'));
> $CREDIT_REQUEST_DATA->setAttribute('CreditRequestID','CRReq0001');
> $CREDIT_REQUEST_DATA->setAttribute('BorrowerID','BorRec0001');
> $CREDIT_REQUEST_DATA->setAttribute('CreditReportRequestActionType','Submit');
> $CREDIT_REQUEST_DATA->setAttribute('CreditReportType','Consumer');
> $CREDIT_REQUEST_DATA->setAttribute('CreditRequestType','Individual');
>
> $CREDIT_REPOSITORY_INCLUDED=$CREDIT_REQUEST_DATA->appendChild($dom->createElement('CREDIT_REPOSITORY_INCLUDED'));
> $CREDIT_REPOSITORY_INCLUDED->setAttribute('_EquifaxIndicator','N');
> $CREDIT_REPOSITORY_INCLUDED->setAttribute('_ExperianIndicator','Y');
> $CREDIT_REPOSITORY_INCLUDED->setAttribute('_TransUnionIndicator','N');
>
> $LOAN_APPLICATION=$CREDIT_REQUEST->appendChild($dom->createElement('LOAN_APPLICATION'));
> $BORROWER=$LOAN_APPLICATION->appendChild($dom->createElement('BORROWER'));
> $BORROWER->setAttribute('BorrowerID','BorRec0001');
> $BORROWER->setAttribute('_FirstName','EVPAULA');
> $BORROWER->setAttribute('_MiddleName','');
> $BORROWER->setAttribute('_LastName','Consumer');
> $BORROWER->setAttribute('_SSN','376988419');
>
>
> $_RESIDENCE=$BORROWER->appendChild($dom->createElement('_RESIDENCE'));
> $_RESIDENCE->setAttribute('_StreetAddress','10655 Birch St');
> $_RESIDENCE->setAttribute('_City','Burbank');
> $_RESIDENCE->setAttribute('_State','Ca');
> $_RESIDENCE->setAttribute('_PostalCode','20906');
>
> $dom -> formatOutput = true;
> $result= $dom->saveXML();
> //echo $result;
> ?>
>
>
>
>
> Michael Horowitz
> Your Computer Consultant
> http://yourcomputerconsultant.com
> 561-394-9079
>
>
>
> Daniel Stenberg wrote:
>> On Tue, 18 Mar 2008, Michael Horowitz wrote:
>>
>>> I think it needs to come in as a string and not an array. Am I
>>> correct in thinking that?
>>>
>>> Thanks for any help people can give me
>>
>> Did you pass a string or a hash array to CURLOPT_POSTFIELDS when you
>> send the POST?
>>
>
>
> ------------------------------
>
> Message: 7
> Date: Tue, 18 Mar 2008 21:58:46 +0100 (CET)
> From: Daniel Stenberg
> Subject: Re: curl and xml problem
> To: curl with PHP
> Message-ID:
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Tue, 18 Mar 2008, Michael Horowitz wrote:
>
>> Here is the code I am using. I am sending a string.
>
>> curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlResult);
>
> This this sends the data as a regular POST...
>
>> The xml shows up after it is posted as array(1) { ["
>> string(972) "\"1.0\"?>
>
> ... and this weird splitting up the received data in "var=data" pairs is done
> by the receiving end => PHP code => stuff I know next to nothing about.
>
>
> ------------------------------
>
> Message: 8
> Date: Tue, 18 Mar 2008 17:43:26 -0400
> From: Michael Horowitz
> Subject: Re: curl and xml problem
> To: curl with PHP
> Message-ID:
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> When people normally post xml data with curl how does it come out. Is
> the normal method for it to look like an array or a string?
>
> Michael Horowitz
> Your Computer Consultant
> http://yourcomputerconsultant.com
> 561-394-9079
>
>
>
> Daniel Stenberg wrote:
>> On Tue, 18 Mar 2008, Michael Horowitz wrote:
>>
>>
>>> Here is the code I am using. I am sending a string.
>>>
>>
>>
>>> curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlResult);
>>>
>>
>> This this sends the data as a regular POST...
>>
>>
>>> The xml shows up after it is posted as array(1) { ["
>>> string(972) "\"1.0\"?>
>>>
>>
>> ... and this weird splitting up the received data in "var=data" pairs is done
>> by the receiving end => PHP code => stuff I know next to nothing about.
>> _______________________________________________
>> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>>
>>
>
>
> ------------------------------
>
> Message: 9
> Date: Tue, 18 Mar 2008 22:51:47 +0100 (CET)
> From: Daniel Stenberg
> Subject: Re: curl and xml problem
> To: curl with PHP
> Message-ID:
> Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed
>
> On Tue, 18 Mar 2008, Michael Horowitz wrote:
>
>> When people normally post xml data with curl how does it come out. Is
>> the normal method for it to look like an array or a string?
>
> That's normally not our concern. curl and libcurl send POSTs, the receiving
> end is not (lib)curl stuff and thus we don't tend to talk about it here...
>
> In my own scripts I always receive posted content the way I think is most
> suitable for the particular script/site I'm writing.
>
> I suppose you should ask in a more generic PHP forum on how people in general
> receive their POSTs.
>
> --
> Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
>
>
> ------------------------------
>
> Message: 10
> Date: Tue, 18 Mar 2008 18:14:41 -0400
> From: Michael Horowitz
> Subject: Re: curl and xml problem
> To: curl with PHP
> Message-ID:
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> The reason I thought here is that I am using curl with php. Generally
> when I do regular html posts they com out as an array from a form.
> Never worked with curl before but it seems its primarily works in this
> type of instance as a surrogate for a form. However I wanted to see if
> people did anything special with regards to xml.
>
>
> Michael Horowitz
> Your Computer Consultant
> http://yourcomputerconsultant.com
> 561-394-9079
>
>
>
> Daniel Stenberg wrote:
>> On Tue, 18 Mar 2008, Michael Horowitz wrote:
>>
>>
>>> When people normally post xml data with curl how does it come out. Is
>>> the normal method for it to look like an array or a string?
>>>
>>
>> That's normally not our concern. curl and libcurl send POSTs, the receiving
>> end is not (lib)curl stuff and thus we don't tend to talk about it here...
>>
>> In my own scripts I always receive posted content the way I think is most
>> suitable for the particular script/site I'm writing.
>>
>> I suppose you should ask in a more generic PHP forum on how people in general
>> receive their POSTs.
>>
>> --
>> Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
>> _______________________________________________
>> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>>
>>
>
>
> ------------------------------
>
> _______________________________________________
> curl-and-php mailing list
> curl-and-php_at_cool.haxx.se
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
>
>
> End of curl-and-php Digest, Vol 31, Issue 10
> ********************************************
_________________________________________________________________
Your chance to win great prizes with Windows Live Mail and Rogers MobileMail. Click here to learn how.
http://g.msn.ca/ca55/207
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2008-03-19