[英]cURL with PHP - HTTP cURL to HTTPS
我有以下PHP, 可在本地工作(通過apache和localhost),但不能在我的主機上使用- $response
始終為空:
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$api_key = 'my_api_key';
$randomString = generateRandomString(10);
$endLabel = sha1(md5($randomString));
$user_id = $endLabel;
$amount_doge = '5';
$url = "https://dogeapi.com/wow/?api_key=".$api_key."&a=get_new_address&address_label=".$user_id;
$response = get_data($url);
我想知道是否可能是因為我托管在HTTP(無SSL選項)上,並且正在調用HTTPS域? 如果是這樣,是否有辦法解決? 我試過curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
但它似乎無能為力:(
嘗試在$data = curl_exec($ch);
之后使用echo curl_error($ch)
$data = curl_exec($ch);
看看卷曲的意思會告訴你發生了什么
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.