Zuerst ein Sitzungstoken erhalten.
$apikey = 'YOUR API KEY HERE';
$appid = 'APPLICATIONID';
$email = '[email protected]';
$passwd = 'PASSWORD';
$params = http_build_query(array(
'email' => $email,
'password'=> $passwd,
'application_id' => $appid,
'signature' => sha1("$email$passwd$appid$apikey"),
'response_format' => 'json'
));
$fp = fopen('https://www.mediafire.com/api/user/get_session_token.php?'.$params, 'r');
$json = stream_get_contents($fp);
$obj = json_decode($json);
fclose($fp);
$session = $obj->response->session_token;
Jetzt mit diesem neuen $session
Schlüssel Upload einer Datei.
$filecontents = file_get_contents("/path/to/file");
$filesize = strlen($filecontents);
$opts = array(
'http'=>array(
'method'=>"POST",
'header'=> "x-filename : ANYFILENAMEYOUWANT\r\n".
"x-filesize : $filesize\r\n"
)
);
$context = stream_context_create($opts);
$params = http_build_query(array(
"session_token" => $session
));
$fp = fopen('http://www.mediafire.com/api/upload/upload.php?'.$params, 'r', false, $context);
fwrite($fp, $filecontents);
$result = stream_get_contents($fp);
fclose($fp);
Wichtiger Hinweis: Bitte versuchen Sie es selbst. Ich habe es nicht getestet. Habe gerade die API gesehen und diesen Code geschrieben. So wird es nicht auf Anhieb funktionieren. Sie müssen ändern, damit es funktioniert.
Sie haben eine Antwort auf Ihre eigene Frage gegeben: http://developers.mediafire.com/index.php/REST_API und genauer gesagt: http://developers.mediafire.com/index.php/REST_API#upload – Supericy