我得到一個奇怪的服務器php捲曲錯誤在我的本地和生產服務器(Ubuntu 14.04.2 LTS, PHP 5.5.9-1ubuntu4.11, Apache 2.4.7
)。curl - 請求與wp_remote_get()響應500,curl_exec響應200
基本上,對遠程API的捲髮請求返回狀態碼500響應,僅在wp_remote_get()
中返回狀態200,並返回curl_exec()
和瀏覽器請求。
我調試代碼:
<?php
$url = 'https://yoast.com?edd_action=activate_license&license=my-license-key-here&item_name=WooCommerce+Yoast+SEO&url=https://google.com';
// this return status 200:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
echo '<pre>' . print_r($result, true) . '</pre>';
// this return status 500:
$testResp = wp_remote_get($url);
echo '<pre>' . print_r($testResp, true) . '</pre>';
我想不通爲什麼它響應500 wp_remote_get()
。我試過調整參數傳遞到wp_remote_get()
,但仍然是與它。
我也禁用了所有調試插件。
任何想法?