Now Delicious is closing down, I tried to make a PHP form for a few friends to use to download there bookmarks:
Vising this url: https://api.del.icio.us/v1/posts/all
You get prompted for a username and password then presented with XML, I want to automate the download of the XML returned.
<?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>开发者_JS百科
<td>
<input TYPE="submit" tabindex="3" value="Submit!">
</td>
</tr>
</table>
</form>
Im missing something here but cant see what? Any help appreciated : )
Well, I'm not familiar with Delicious API, but my first suggestions is not to use undefined variables:
<?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);
?>
精彩评论