脚本宝典收集整理的这篇文章主要介绍了Mediafire API PHP开发,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
http://developers.mediafire.com
我在互联网上搜索是为了使用API创建一个上传文件到mediafire帐户的网络应用程序.不幸的是我没有找到任何东西.有人知道如何使用Mediafire API和PHP创建上传Web应用程序的文件.
$apikey = 'YOUR API KEY HERE'; $appid = 'APPLICATIONID'; $email = 'your@email.COM'; $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;
$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);
重要说明:请亲自尝试.我没有测试过.刚看到API并编写了这段代码.所以它不会在第一次工作.您需要进行修改才能使其正常工作.
以上是脚本宝典为你收集整理的Mediafire API PHP开发全部内容,希望文章能够帮你解决Mediafire API PHP开发所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。