PHP Guzzle对发布请求的空响应

时间:2017-10-04 01:28:13

标签: php drupal guzzle

我实现了一个Drupal WebForm处理程序,用于在提交后将数据发布到PayU Web Checkout Integration,经过几个小时的尝试,我开始认为Guzzle客户端存在问题,所以我从Drupal单独测试。我使用了一个简单的Rest API GET请求并且工作正常,但是这个POST请求仍然没有返回任何内容,我已经尝试了从使用流到改变Guzzle版本的所有内容here。我也使用过Postman,那里的事情很好。

<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);

require_once './vendor/autoload.php';

use GuzzleHttp\Client;
use GuzzleHttp\Psr7;
//use GuzzleHttp\Stream\Stream;



try {            
    $client = new Client();            
    //$post_url = $this->configuration['submission_url'];
    $post_url = 'https://sandbox.gateway.payulatam.com/ppp-web-gateway';               

    //$response = $client->request('GET', $post_url);



    $response = $client->request('POST', $post_url,[ 
        'debug' => true,       
        'form_params' => [                 
            'merchantId' => '508029',
            'ApiKey' => '4Vj8eK4rloUd272L48hsrarnUA',
            'referenceCode' => 'TestPayU',
            'accountId' => '512326',
            'description' => 'Test PAYU',
            'amount' => '3',
            'tax' => '0',
            'taxReturnBase' => '0',
            'currency' => 'USD',
            'signature' => 'ba9ffa71559580175585e45ce70b6c37',
            'test' => '1',
            'buyerEmail' => 'test@test.com'   
        ]               
    ]); 


    //$response = Psr7\stream_for($response->getBody());    
    var_dump($response->getBody()->getContents());    

}
catch(Exception $e) {
    echo($e->getMessage());
}

这是调试报告。我很感激任何帮助。感谢。

    * Trying 69.20.41.99... * Connected to sandbox.gateway.payulatam.com 
   (69.20.41.99) port 443 (#0) * Cipher selection: 
   ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * 
   successfully set certificate verify locations: * CAfile: 
   /Applications/DevDesktop/common/cert/cacert.pem CApath: none * SSL 
   connection using TLSv1.2 / AES256-SHA256 * Server certificate: * 
   subject: OU=Domain Control Validated; OU=COMODO SSL Unified 
   Communications; CN=payulatam.com * start date: 2017-06-07 00:00:00 GMT * 
   expire date: 2019-06-05 23:59:59 GMT * subjectAltName: 
   sandbox.gateway.payulatam.com matched * issuer: C=GB; ST=Greater 
   Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO RSA Domain 
   Validation Secure Server CA * SSL certificate verify ok. > POST /ppp-
   web-gateway HTTP/1.1 Host: sandbox.gateway.payulatam.com User-Agent: 
   GuzzleHttp/6.2.1 curl/7.44.0 PHP/7.0.14 Content-Type: application/x-www-
   form-urlencoded Content-Length: 234 * upload completely sent off: 234 
   out of 234 bytes < HTTP/1.1 302 Found < Set-Cookie: 
   JSESSIONID=79253C01031875A1B442649D8B824674.gateway-nodo1; 
   Path=/ppp-web-gateway/; Secure; HttpOnly < X-FRAME-OPTIONS: 
   SAMEORIGIN < Set-Cookie: cookie-pol-checkout-version_512326=V2; 
   Expires=Fri, 28-Sep-2018 22:54:23 GMT; Path=/ppp-web-gateway/; 
   Secure < Location: /ppp-web-gateway/page-redirect.zul < Content-
   Length: 0 < Date: Tue, 03 Oct 2017 22:54:22 GMT < Server: PayU 
   server < * Connection #0 to host sandbox.gateway.payulatam.com left 
   intact * Found bundle for host sandbox.gateway.payulatam.com: 
   0x7918c650 * Re-using existing connection! (#0) with host 
   sandbox.gateway.payulatam.com * Connected to 
   sandbox.gateway.payulatam.com (69.20.41.99) port 443 (#0) > GET 
   /ppp-web-gateway/page-redirect.zul HTTP/1.1 Host: 
   sandbox.gateway.payulatam.com User-Agent: GuzzleHttp/6.2.1 
   curl/7.44.0 PHP/7.0.14 Content-Type: application/x-www-form-
   urlencoded < HTTP/1.1 200 OK < Set-Cookie: 
   JSESSIONID=EF0110093412FCDF3E56DD15F1937F30.gateway-nodo1; 
   Path=/ppp-web-gateway/; Secure; HttpOnly < X-FRAME-OPTIONS: 
   SAMEORIGIN < Set-Cookie: cookie-
   pol=pol_190_238_194_79_1507071263918; Domain=pagosonline.net; 
   Expires=Fri, 28-Sep-2018 22:54:23 GMT; Path=/; Secure < Content-
   Language: en-US < Content-Length: 0 < Date: Tue, 03 Oct 2017 
   22:54:22 GMT < Server: PayU server < * Connection #0 to host 
   sandbox.gateway.payulatam.com left intact string(0) ""

0 个答案:

没有答案
相关问题