1.在官网下载php zip安装包
2.在php中开启curl模块
首先使用phpinfo()方法查看当前php环境的php.ini文件位置 我的在c:\windows,然后
在php压缩目录复制一个php.ini-develipment到c:\windows,并将php安装目录下ext文
件夹copy至c:\windows目录下
编辑c:\windows目录下的php.ini
//去掉之前的冒号
extension=curl
//将extension_dir设置为ext目录
extension_dir = "ext"
3.下载PHPStorm
新建一个php empty project
4.在websotrm中指定php位置
5.curl basic认证代码
<?php
//phpinfo();
$url = 'url';
$username = 'username';
$password = 'api-key';
$curl =curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_USERPWD, "$username:$password");
//curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
//curl_setopt($curl, CURLOPT_USERPWD, "[$username]:[$password]");
$res = curl_exec($curl);
echo($res);
$status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
echo($status_code);
curl_close($curl);
?>