Hey Guys, I'm having a really hard time to figure out this API for MediaFire. Would anyone have any suggestions on what I could do? I basically just want a script that will upload to MediaFire, and then return me with some value that I can use for finding the URL of the file on MediaFire. Here's the error I'm getting I'm using Xampp. Warning: fopen(http://www.mediafire.com/api/upload...278b6d0254272e324639895cb9fcac6e71c00ce461ce2): failed to open stream: HTTP request failed! HTTP/1.1 400 in C:\xampp\htdocs\index.php on line 435 So it looks like fopen is working. The first fopen in my code appears to be grabbing that session ID from their systems, but then then the second one fails. (line 435 is the second fopen) Here's my code so far. $apikey = 'myapikey'; $appid = 'myappid'; $email = 'myemail'; $passwd = 'mypassword'; $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("testfile.pdf"); $filesize = strlen($filecontents); $opts = array('http'=>array('method'=>"POST",'header'=>"x-filename : testfile.pdf\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); PHP: When running this script, the testfile.pdf does not get uploaded. Any ideas?
I'm now using another script at "https://github.com/windylea/mediafire-api-php-library/blob/master/example/file_upload.php" that seems to be working. It calls on another file named "mflib.php". It works great! But the part is, I can't figure out how to get the URL from each uploaded file. Like I wouldn't mind if I could just echo the URL somehow. From what I understand, there's something called "quickkey" which is supposed basically the key that is used in the URL. The VAR_DUMP function at the bottom of the script seems to print out a bunch of information (including the quickkey), but it always seems blank for some reason. Not to mention that I also wouldn't know how to extract the quickkey from that even if there was one :| Any ideas?