Wordpress Plugin을 사용하려면 CURL에서 wp_remote_post로 PHP 라이브러리를 변환해야합니다.CURL 요청을 Wordpress로 변환 wp_remote_post
참조 번호는 Wordpress wp_remote_post page here입니다.
이
어떤 시점에서$THEurl = $scheme . $url['host'] . $url['path'];
$response = wp_remote_post($THEurl, array(
'method' => 'POST',
'timeout' => 45,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'body' => $query,
'cookies' => array()
)
);
if (is_wp_error($response)) {
$errorResponse = $response->get_error_message();
require_once("FBAOutboundServiceMWS/Exception.php");
curl_close($ch);
throw new FBAOutboundServiceMWS_Exception(array(
'Message' => $errorResponse,
'ErrorType' => 'HTTP'
));
}
는 wp_remote_post
을한다 ...
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $scheme . $url['host'] . $url['path']);
curl_setopt($ch, CURLOPT_PORT, $port);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_USERAGENT, $this->_config['UserAgent']);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = "";
$response = curl_exec($ch);
if ($response === false) {
$errorResponse = curl_error($ch);
require_once("FBAOutboundServiceMWS/Exception.php");
curl_close($ch);
throw new FBAOutboundServiceMWS_Exception(array(
'Message' => $errorResponse,
'ErrorType' => 'HTTP'
));
}
curl_close($ch);
이 내가 '생각'올바른 무엇지만 작동하지 않습니다 .. 제가 변환하려고 시도하는 코드입니다 실제로 사형 당해? 함수가 호출되었을 때? 사전에 도움을 많은 감사)
슈퍼 유용한 정보 .- @Hobo –
오류 코드가 있습니까? 오류 로그에 아무것도 표시되지 않습니까? 나는 네가하는 일에 많은 잘못을 느낀다. '$ query' 변수의 내용은 무엇입니까? 또한 내가 왜 잘못 curl_close() 오류 영역에서 실행하는지 모르겠다. – Stewartside