//Нужно чтобы эти настройки у курла были по умолчанию //curl_setopt($this->curl, CURLOPT_HTTPHEADER, $this->header); //curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, 1); // curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1); // curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false); //curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false); class YandexDisk { private $token = 'AQAEA7qiKBKFAATDAPzhf55jkU3QlCext-2UxOw'; private $header = array(); private $curl; function __construct() { $this->header = array('Accept: application/json','Authorization: OAuth '.$this->token); $this->curl = curl_init(); curl_setopt($this->curl, CURLOPT_HTTPHEADER, $this->header); curl_setopt($this->curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($this->curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, false); } public function uploadFile($url,$name) { $url = "https://cloud-api.yandex.net/v1/disk/resources/upload?path=$name.mp3&url=$url&overwrite=true"; curl_setopt($this->curl, CURLOPT_URL, $url); curl_setopt($this->curl, CURLOPT_POST, 1); $result = curl_exec($this->curl); curl_close($this->curl); return $result; } public function createFolder($name) { $url = "https://cloud-api.yandex.net/v1/disk/resources/?path=$name"; curl_setopt($this->curl, CURLOPT_URL, $url); curl_setopt($this->curl, CURLOPT_PUT, true); $result = curl_exec($this->curl); curl_close($this->curl); return $result; } public function getUrl($id) { $url = "https://cloud-api.yandex.net/v1/disk/resources?path=$name"; curl_setopt($this->curl, CURLOPT_URL, $url); curl_setopt($this->curl, CURLOPT_PUT, true); $result = curl_exec($this->curl); curl_close($this->curl); return $result; } }