您好我正在尝试发布数据使用PHP中的CURL来diigo书签,我已经尝试通过API,当我执行文件时我得到HTTP基本身份验证这里是我的代码
require_once('libs/diigo.class.php');
$diggo = new DiigoAPI("username","password");
$book = $diggo->getBookmarks();
$diggo->saveBookmarks("http://www.example.com");
public function saveBookmarks($url)
{
$attachment = array ("url" => $url, "title" => "SEnthil" , "shared" => "yes" );
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://secure.diigo.com/api/v2/bookmarks');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $attachment);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //to suppress the curl output
$result = curl_exec($ch);
echo $result;
curl_close ($ch);
}
答案 0 :(得分:2)
您的curl没有基本的HTTP身份验证设置。你应该这样设置:
curl_setopt($curl, CURLOPT_USERPWD, $user_here . ":" . $password_here );
现在你的方式就是saveBookmarks功能根本不需要Diigo Class。