1. 程式人生 > >新浪微博圖床API

新浪微博圖床API

主要就是這段程式碼,找了老半天才找到,直接拿去用吧:

function uploadpic($picurl,$cookie){
$ch = curl_init('http://picupload.service.weibo.com/interface/pic_upload.php?mime=image%2Fjpeg&data=base64&url=0&markpos=1&logo=&nick=0&marks=1&app=miniblog');

curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_VERBOSE => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => ["Cookie: $cookie"],
    CURLOPT_POSTFIELDS => ['b64_data' => base64_encode(file_get_contents($picurl))],
]);

$res = curl_exec($ch);
curl_close($ch);
print_r($res);	



}
//上傳圖片到新浪 */