[英]How to form PHP curl request for the following command line?
有人可以幫助我在PHP中形成此commndline請求嗎?
$ curl -u [USER:PASSWORD] https://subs.pinpayments.com/api/v4/meresheep/subscribers/7388.xml
我嘗試了以下操作,並且只返回了“ false” ...
// Query the user to pin payments for the details...
$curl_url = "https://subs.pinpayments.com/api/v4/xyz-site/subscribers/32.xml";
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: -u [USER:PASSWORD]'));
//execute post
$result = curl_exec($ch);
curl_close($ch);
您需要更改CURLOPT_HTTPHEADER
行:
curl_setopt($data, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . base64_encode('username:password')
));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.