【发布时间】:2013-07-16 08:29:41
【问题描述】:
我刚刚下载了最新的xampp,这是我第一次使用curl。 我在 appannie 有一个帐户,并且已阅读此处关于他/她尝试访问 appannie 的帖子之一。
这是该帖子的链接: Appannie api basic authentication
好吧,为了简单起见,他编写的代码是:
<?php
$whmusername = "username";
$whmpassword = "password";
$query = "https://api.appannie.com/v1/accounts";
$ch = curl_init();
// Sets the URL cURL will open
curl_setopt($ch, CURLOPT_URL, $query);
// Here's the HTTP auth
// The 3rd argument is your Twitter username and password joined with a colon
curl_setopt($ch, CURLOPT_USERPWD, $whmusername.":".$whmpassword);
// Makes curl_exec() return server response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// And here's the result XML
$response = curl_exec($ch);
curl_close($ch);
// inserted: echo 'hello';
print $response;
// inserted: echo 'world';
?>
我尝试使用它,但没有任何反应。所以我在响应之前和之后都插入了 echo (我在评论中标记了),看看我的 php 网络是否真的在工作并且它只是显示:
hello world
所以我想知道 xampp 中的 curl 库是否已经阅读了这篇文章: curl not working in xampp localhost
在 cmets 中是步骤,但我发现 php 目录中 php.ini 中的 curl 已经不是注释形式,并且 apache 目录中没有 php.ini。
我是我提到的关于 appannie 的第 1 篇文章,我已经将用户名更改为 appannie 中使用的电子邮件帐户。
请帮忙?谢谢
【问题讨论】:
标签: php api curl xampp restful-authentication