如何形成以下命令行PHP卷曲的要求吗? [英] How to form PHP curl request for the following command line?

查看:286
本文介绍了如何形成以下命令行PHP卷曲的要求吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮助我形成在PHP中,这commndline要求?

$卷曲-u [用户名:密码] https://subs.pinpayments.com/api/v4/meresheep/subscribers/7388.xml

我曾尝试以下,并只得到'假'回来......

  //查询用户引脚的细节支付...
 $ curl_url =htt​​ps://subs.pinpayments.com/api/v4/xyz​​-site/subscribers/32.xml; //打开连接
 $ CH = curl_init(); //设置URL,POST数瓦尔,POST数据
 curl_setopt($ CH,CURLOPT_URL,$网址);
 curl_setopt($ CH,CURLOPT_RETURNTRANSFER,1);
 curl_setopt($ CH,CURLOPT_SSL_VERIFYPEER,FALSE);
 curl_setopt($ CH,CURLOPT_HTTPHEADER,阵列('授权:-u [用户名:密码]')); //实行岗位
 $结果= curl_exec($ CH);
 curl_close($ CH);


解决方案

您需要更改 CURLOPT_HTTPHEADER 行:

  curl_setopt($的数据,CURLOPT_HTTPHEADER,阵列(
    授权:基本。 base64_en code('用户名:密码')
));

Can someone help me to form this commndline request in PHP ?

$ curl -u [USER:PASSWORD] https://subs.pinpayments.com/api/v4/meresheep/subscribers/7388.xml

I have tried the following and getting only 'false' returned...

 // 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);

解决方案

You need to change the CURLOPT_HTTPHEADER line:

curl_setopt($data, CURLOPT_HTTPHEADER, array(
    'Authorization: Basic ' . base64_encode('username:password')
));

这篇关于如何形成以下命令行PHP卷曲的要求吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆