Vous n'êtes pas identifié.
Philippe
<?php
class JhebergUploader
{
private $_upload_url;
public function getUrlUpload()
{
$content = json_decode(file_get_contents('http://jheberg.net/api/get/server/'));
$this->_upload_url = $content->url;
}
public function upload($file, $username = false, $password = false)
{
$postData = array(
'file' => '@'.realpath($file),
'username' => $username,
'password' => $password
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->_upload_url.'/api/upload/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
$data = curl_exec($ch);
curl_close($ch);
return json_decode($data, true);
}
}
$jheberg = new JhebergUploader;
$jheberg->getUrlUpload();
print_r($jheberg->upload('a.txt'));
?>