Diigo API——PHP for HTTPS中通过CURL的HTTP基本身份验证错误


Diigo API -- HTTP Basic Authentication Error over CURL in PHP for HTTPS

嗨,我正在尝试发布数据使用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);
    }

您的curl没有基本的HTTP身份验证集。你应该这样设置:

curl_setopt($curl, CURLOPT_USERPWD, $user_here . ":" . $password_here );

现在的做法是saveBookmarks函数根本不需要Diigo类。