在cur中卷曲的问题?

时间:2010-09-15 05:51:21

标签: php curl

我正在使用curl从Emailvision向API发送xml请求。我最近遇到麻烦,有些请求导致“500内部服务器错误”,而其他请求则没有任何错误发送。

下面粘贴了详细的输出,有人可以帮我解释可能导致错误的原因。

* About to connect() to api.notificationmessaging.com port 443
*   Trying 81.92.116.8... * connected
* Connected to api.notificationmessaging.com (81.92.116.8) port 443
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using RC4-MD5
* Server certificate:
*        subject: /C=FR/ST=Hauts de Seine/L=Clichy/O=Emailvision/OU=Provided by TBS INTERNET http://www.tbs-certificats.com//CN=*.notificationmessaging.com
*        start date: 2008-09-20 09:09:15 GMT
*        expire date: 2010-09-20 09:09:15 GMT
*        issuer: /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premium Server CA/emailAddress=premium-server@thawte.com
* SSL certificate verify ok.
POST /NMSXML HTTP/1.1
Host: api.notificationmessaging.com
Accept: */*
Content-Length: 2177
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue

HTTP/1.1 100 Continue
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  2177    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0 HTTP/1.1 200 OK
 Date: Wed, 15 Sep 2010 05:15:53 GMT
 X-Powered-By: Servlet 2.4; JBoss-4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)/Tomcat-5.5
 Content-Type: application/xml;charset=utf-8
 Content-Length: 82
 Connection: close
100  2259    0    82  100  2177    969  25745 --:--:-- --:--:-- --:--:-- 80629* Closing connection #0

* About to connect() to api.notificationmessaging.com port 443
*   Trying 81.92.116.8... * connected
* Connected to api.notificationmessaging.com (81.92.116.8) port 443
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using RC4-MD5
* Server certificate:
*        subject: /C=FR/ST=Hauts de Seine/L=Clichy/O=Emailvision/OU=Provided by TBS INTERNET http://www.tbs-certificats.com//CN=*.notificationmessaging.com
*        start date: 2008-09-20 09:09:15 GMT
*        expire date: 2010-09-20 09:09:15 GMT
*        issuer: /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premium Server CA/emailAddress=premium-server@thawte.com
* SSL certificate verify ok.
 POST /NMSXML HTTP/1.1
Host: api.notificationmessaging.com
Accept: */*
Content-Length: 21942
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue

 HTTP/1.1 100 Continue
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0 21942    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0 HTTP/1.1 500 Internal Server Error
 Date: Wed, 15 Sep 2010 05:15:52 GMT
 X-Powered-By: Servlet 2.4; JBoss-4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)/Tomcat-5.5
 Content-Type: text/xml
 Content-Length: 0
 Connection: close
100 21942    0     0  100 21942      0   216k --:--:-- --:--:-- --:--:--  535k* Closing connection #0

* About to connect() to api.notificationmessaging.com port 443
*   Trying 81.92.116.8... * connected
* Connected to api.notificationmessaging.com (81.92.116.8) port 443
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using RC4-MD5
* Server certificate:
*        subject: /C=FR/ST=Hauts de Seine/L=Clichy/O=Emailvision/OU=Provided by TBS INTERNET http://www.tbs-certificats.com//CN=*.notificationmessaging.com
*        start date: 2008-09-20 09:09:15 GMT
*        expire date: 2010-09-20 09:09:15 GMT
*        issuer: /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premium Server CA/emailAddress=premium-server@thawte.com
* SSL certificate verify ok.
 POST /NMSXML HTTP/1.1
Host: api.notificationmessaging.com
Accept: */*
Content-Length: 11602
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue

 HTTP/1.1 100 Continue
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0 11602    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0 HTTP/1.1 500 Internal Server Error
 Date: Wed, 15 Sep 2010 05:15:52 GMT
 X-Powered-By: Servlet 2.4; JBoss-4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)/Tomcat-5.5
 Content-Type: text/xml
 Content-Length: 0
 Connection: close
100 11602    0     0  100 11602      0   118k --:--:-- --:--:-- --:--:--  306k* Closing connection #0

* About to connect() to api.notificationmessaging.com port 443
*   Trying 81.92.116.8... * connected
* Connected to api.notificationmessaging.com (81.92.116.8) port 443
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using RC4-MD5
* Server certificate:
*        subject: /C=FR/ST=Hauts de Seine/L=Clichy/O=Emailvision/OU=Provided by TBS INTERNET http://www.tbs-certificats.com//CN=*.notificationmessaging.com
*        start date: 2008-09-20 09:09:15 GMT
*        expire date: 2010-09-20 09:09:15 GMT
*        issuer: /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premium Server CA/emailAddress=premium-server@thawte.com
* SSL certificate verify ok.
 POST /NMSXML HTTP/1.1
Host: api.notificationmessaging.com
Accept: */*
Content-Length: 2178
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue

 HTTP/1.1 100 Continue
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  2178    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0 HTTP/1.1 200 OK
 Date: Wed, 15 Sep 2010 05:15:53 GMT
 X-Powered-By: Servlet 2.4; JBoss-4.0.5.GA (build: CVSTag=Branch_4_0 date=200610162339)/Tomcat-5.5
 Content-Type: application/xml;charset=utf-8
 Content-Length: 82
 Connection: close
100  2260    0    82  100  2178    777  20644 --:--:-- --:--:-- --:--:-- 45375* Closing connection #0

* About to connect() to api.notificationmessaging.com port 443
*   Trying 81.92.116.8... * connected
* Connected to api.notificationmessaging.com (81.92.116.8) port 443
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
  CApath: none
* SSL connection using RC4-MD5
* Server certificate:
*        subject: /C=FR/ST=Hauts de Seine/L=Clichy/O=Emailvision/OU=Provided by TBS INTERNET http://www.tbs-certificats.com//CN=*.notificationmessaging.com
*        start date: 2008-09-20 09:09:15 GMT
*        expire date: 2010-09-20 09:09:15 GMT
*        issuer: /C=ZA/ST=Western Cape/L=Cape Town/O=Thawte Consulting cc/OU=Certification Services Division/CN=Thawte Premium Server CA/emailAddress=premium-server@thawte.com
* SSL certificate verify ok.
 POST /NMSXML HTTP/1.1
Host: api.notificationmessaging.com
Accept: */*
Content-Length: 2178
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue

HTTP/1.1 100 Continue
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  2178    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

以下是我用来提出请求的卷曲片段。

curl_setopt($ch,
CURLOPT_URL,'https://api.notificationmessaging.com/NMSXML');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $sXML);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 600);
curl_setopt($ch, CURLOPT_VERBOSE, TRUE);
curl_setopt($ch, CURLOPT_NOPROGRESS, 0);
$res = curl_exec($ch);

有人可以帮忙。

谢谢

更新 发现问题出现在xml中的某些字符如â,正如Mark所指出的那样。现在有没有办法删除/转换xml中无法识别的所有字符?

1 个答案:

答案 0 :(得分:2)

500意味着他们的系统存在编程错误,而不是您的系统。它可能是由你发送错误参数引起的,但他们应该以不同的方式处理它。

我告诉公司你正在做的事情是造成500,他们应该能够解决它。