PHP Yii2 HTTP 客户端调试
PHP Yii2 HTTP Client Debugging
我正在尝试使用 ZEND Http 客户端在文档中举例说明的 Yii HTTP 客户端(正在开发中)重写以下 HTTP 请求:
// Create Http client to send the paymentRequest
// We use Zend_Http_Client here, feel free to use your favourite HTTP client library
$client = new Zend_Http_Client($this->donationRequest->getSipsUri());
$client->setParameterPost('Data', $this->donationRequest->toParameterString());
$client->setParameterPost('InterfaceVersion', 'HP_2.3');
$client->setParameterPost('Seal', $this->donationRequest->getShaSign());
$response = $client->request(Zend_Http_Client::POST);
使用 Yii,这是我想出的:
$client = new Client();
$data = [
'Data' => $this->donationRequest->toParameterString(),
'InterfaceVersion' => 'HP_2.3',
'Seal' => $this->donationRequest->getShaSign()
];
$client->createRequest()
->setMethod('post')
->setUrl($this->donationRequest->getSipsUri())
->setData($data)->send();
启动此代码时,出现以下错误:
fopen(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname
如何正确调试问题(即查看提交的内容并使用结果通过浏览器解决方案进行测试)?
关于使用 Yii 替代方案生成与 Zend 示例类似的请求的任何建议
我改用了 Guzzle,它与 Yii2 配合得很好,并且界面非常简单。谢谢
我正在尝试使用 ZEND Http 客户端在文档中举例说明的 Yii HTTP 客户端(正在开发中)重写以下 HTTP 请求:
// Create Http client to send the paymentRequest
// We use Zend_Http_Client here, feel free to use your favourite HTTP client library
$client = new Zend_Http_Client($this->donationRequest->getSipsUri());
$client->setParameterPost('Data', $this->donationRequest->toParameterString());
$client->setParameterPost('InterfaceVersion', 'HP_2.3');
$client->setParameterPost('Seal', $this->donationRequest->getShaSign());
$response = $client->request(Zend_Http_Client::POST);
使用 Yii,这是我想出的:
$client = new Client();
$data = [
'Data' => $this->donationRequest->toParameterString(),
'InterfaceVersion' => 'HP_2.3',
'Seal' => $this->donationRequest->getShaSign()
];
$client->createRequest()
->setMethod('post')
->setUrl($this->donationRequest->getSipsUri())
->setData($data)->send();
启动此代码时,出现以下错误:
fopen(): php_network_getaddresses: getaddrinfo failed: No address associated with hostname
如何正确调试问题(即查看提交的内容并使用结果通过浏览器解决方案进行测试)?
关于使用 Yii 替代方案生成与 Zend 示例类似的请求的任何建议
我改用了 Guzzle,它与 Yii2 配合得很好,并且界面非常简单。谢谢