cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

RE: Curl won't post

From: Etienne Andreoni <etienne.sqad_at_gmail.com>
Date: Fri, 3 Apr 2009 08:43:25 +0200

Bonjour,

 

Etes vous français ???

 

Le problème ne viens vraiment pas de la.

 

J’ai bien chercher pendant 2 jours sur Google, et pas de problèmes
identiques.

 

Comment expliquez vous que le même code fonctionne sur Windows en post et
que sous linux il passe tout seul en get ?

 

Serait-ce un problème de configuration de php curl. Dans mon phpinfo, curl
aparait bien avec ssl.

 

Je suis un peu désespéré. Faut il ajouter aussi libcurl.so au php.ini en
plus du curl.so ?

 

Merci d’avance,

 

Cordialement,

 

Etienne ANDREONI

 <mailto:etienne.sqad_at_gmail.com> etienne.sqad_at_gmail.com

 

De : curl-and-php-bounces_at_cool.haxx.se
[mailto:curl-and-php-bounces_at_cool.haxx.se] De la part de
no-return_at_cardiff.fr
Envoyé : vendredi 3 avril 2009 07:23
À : 'curl with PHP'
Objet : RE: Curl won't post

 

Why do you change $ch to $curl…

Headers are most probably not sent correctly…

 

For your post I’d use personnaly :

            curl_setopt($ch, CURLOPT_HEADER, 0);

            curl_setopt($ch, CURLOPT_HTTPHEADER, "Content-Type:
application/x-www-form-urlencoded");

 

 

It works in any case for me and allows me to send to French ministry
services, SOAP XML DATA and HEADERS

 

Google also around curl problems on application / forms I think I read
things stumbling along with my post problems…

 

Good Luck

 

Tdldp

 

De : curl-and-php-bounces_at_cool.haxx.se
[mailto:curl-and-php-bounces_at_cool.haxx.se] De la part de Etienne Andreoni
Envoyé : jeudi 2 avril 2009 21:05
À : curl-and-php_at_cool.haxx.se
Objet : Curl won't post

 

Hello,

 

I have a problem with the curl and php on linux (Mandriva 2009).

 

I create a script to make a post request to a server with parameters.

 

On my Windows configuration the script works well, but on Linux, the request
is always send in GET.

 

Here is my code :

 

$ch = curl_init();

 

            curl_setopt($ch, CURLOPT_URL, self::$url);

            curl_setopt($ch, CURLOPT_TIMEOUT, 9000);

            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30000);

            curl_setopt($ch, CURLOPT_FAILONERROR, 0);

            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

            curl_setopt($ch, CURLOPT_USERAGENT, "http://toto.com");

            curl_setopt($ch, CURLOPT_REFERER, "Mozilla/4.0 (compatible; MSIE
5.01; Windows NT 5.0)");

            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

            curl_setopt($ch, CURLOPT_HEADER, 1);

            curl_setopt($ch, CURLOPT_VERBOSE, 1);

            curl_setopt($curl, CURLOPT_HTTPHEADER, "Content-Type:
application/x-www-form-urlencoded");

            curl_setopt($ch, CURLOPT_POST, 1);

            curl_setopt($ch, CURLOPT_HTTPGET, 0);

            curl_setopt($ch, CURLOPT_POSTFIELDS, $params);

            curl_setopt($ch, CURLOPT_ENCODING, "");

            curl_setopt($ch, CURLOPT_USERPWD, self::$credentials);

            curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

            curl_setopt($ch, CURLOPT_NOBODY, 0);

            

            $http_code = curl_getinfo($ch);

            

            $data = curl_exec($ch);

 

 

Here is the result on Windows :

 

About to connect() to www.mysite.net port 443 (#0)

        Trying 2.2.2.2... * connected

      Connected to www.mysite.net (2.2.2.2) port 443 (#0)

      SSL connection using DHE-RSA-AES256-SHA

      Server certificate:

             subject: XXXXXXXXXXXXXXX

             start date: 2007-11-20 00:00:00 GMT

             expire date: 2010-12-21 23:59:59 GMT

             issuer: XXXXXXXXXXXXX

      SSL certificate verify result: self signed certificate in certificate
chain (19), continuing anyway.

      Server auth using Basic with user 'user'

> POST –- MY URL -- HTTP/1.1

      Authorization: Basic XXXXXXXXXXXXXXXXXXX

      User-Agent: http://toto.com

      Host: www.eloquant2.net

      Accept: */*

      Accept-Encoding: deflate, gzip

      Referer: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)

      Content-Length: 228

      Content-Type: application/x-www-form-urlencoded

      < HTTP/1.1 200 OK

      < Date: Thu, 02 Apr 2009 17:53:15 GMT

      < Server: Apache Coyote/1.0

      < Cache-Control: no-cache

      < Content-Type: text/plain

      < Content-Length: 6

      < Set-Cookie: JSESSIONID=DBC56B06E5145F7D3EDF2E6214D16CC5; Path=/red

      Connection #0 to host My URL left intact

      Closing connection #0

 

And this is the Linux Result :

 

 

About to connect() to www.mysite.net port 443 (#0)

* Trying 2.2.2.2... * connected

* Connected to www.mysite.net (2.2.2.2) port 443 (#0)

* successfully set certificate verify locations:

* CAfile: /etc/pki/tls/certs/ca-bundle.crt

  CApath: none

* SSL connection using DHE-RSA-AES256-SHA

* Server certificate:

* subject: XXXXXX

* start date: 2007-11-20 00:00:00 GMT

* expire date: 2010-12-21 23:59:59 GMT

* issuer: XXXXX

* SSL certificate verify ok.

* Server auth using Basic with user 'user'

> GET –URL-- HTTP/1.1

Authorization: Basic XXXXXXXXXXX

User-Agent: http://toto.com

Host: www.mysite.net

Accept: */*

Accept-Encoding: deflate, gzip

Referer: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)

 

< HTTP/1.1 200 OK

HTTP/1.1 200 OK

< Date: Thu, 02 Apr 2009 16:10:32 GMT

Date: Thu, 02 Apr 2009 16:10:32 GMT

< Server: Apache Coyote/1.0

Server: Apache Coyote/1.0

< Cache-Control: no-cache

Cache-Control: no-cache

< Content-Type: text/html

Content-Type: text/html

< Content-Length: 1433

Content-Length: 1433

< Set-Cookie: JSESSIONID=7B0EE5F0175436B4DCF4F85A85933D46; Path=/red

Set-Cookie: JSESSIONID=7B0EE5F0175436B4DCF4F85A85933D46; Path=/red

 

 

 

I tried all but no way.

 

I also try to set curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');

It make POST request but no parameters are sent.

 

Could you please help me.

 

Thank you.

 

 

Cordialement,

 

Etienne ANDREONI

etienne.sqad_at_gmail.com

 

__________ Information provenant d'ESET NOD32 Antivirus, version de la base
des signatures de virus 3984 (20090402) __________

Le message a été vérifié par ESET NOD32 Antivirus.

http://www.eset.com

__________ Information provenant d'ESET NOD32 Antivirus, version de la base
des signatures de virus 3984 (20090402) __________

Le message a été vérifié par ESET NOD32 Antivirus.

http://www.eset.com

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2009-04-03