Now Delicious正在关闭,我试图为几个朋友制作一个PHP表格来下载书签:
宣传此网址:https://api.del.icio.us/v1/posts/all
系统会提示您输入用户名和密码,然后显示XML,我想自动下载返回的XML。
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$username = $_POST['username'];
$password = $_POST['password'];
$url = "https://api.del.icio.us/v1/posts/all"
?>
<form ACTION="<?php echo $PHP_SELF;?>" name="bookmarkform" METHOD="POST" align="center">
<table>
<tr>
<td>
<label>Username</label>
</td>
<td>
<input NAME="username" tabindex="1">
</td>
</tr>
<tr>
<td>
<label>Password</label>
</td>
<td>
<input NAME="password" tabindex="2">
</td>
</tr>
<tr>
<td>
</td>
<td>
<input TYPE="submit" tabindex="3" value="Submit!">
</td>
</tr>
</table>
</form>
我在这里遗漏了一些东西但是看不到什么?任何帮助表示赞赏:)
答案 0 :(得分:0)
好吧,我不熟悉Delicious API,但我的第一个建议是不要使用未定义的变量:
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$url = "https://api.del.icio.us/v1/posts/all"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
?>