Uploading to FileSonic Using cURL

Status
Not open for further replies.
The function is for uploading :|

I know that, I'm trying to make one for downloading, could you give a help?

Follow the code for filesonic:
Code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.filesonic.com/user/login");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "email=xxxxxxxxx&redirect=%2F&password=xxxxxxxx&rememberMe=1");
$output = curl_exec($ch);
curl_close($ch);
echo $output;

The problem is not logging in. Any idea? :'(
 
Thanks for the share gunda this is a very good learning experience!

If anyone has insight on how to measure file upload progress, can they explain in post or via PM. Thanks!
 
I know that, I'm trying to make one for downloading, could you give a help?

Follow the code for filesonic:
Code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.filesonic.com/user/login");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "email=xxxxxxxxx&redirect=%2F&password=xxxxxxxx&rememberMe=1");
$output = curl_exec($ch);
curl_close($ch);
echo $output;

The problem is not logging in. Any idea? :'(
Hint: Store the cookie :P
 
I'm not familiar with cookie, can you make a code example for me?

Code:
p=md5(md5(password)email)

PHP exemple:
     $clearTextPassword = '1234';
     $email = 'a@b.c';

     $encryptedPassword = md5(md5($clearTextPassword) . $email);

And yes they show the code, but how I send those variables to File Sonic to I get back the XML file?
 
Are you a Premium member ?
If NO, then the API is of no use to you.

If you're not a Premium member, then there is no need to login to your account.
I think if you do something like this:
Code:
opener.open("http://www.google.com/recaptcha/api/challenge?k=6LdNWbsSAAAAAIMksu-X7f5VgYy8bZiiJzlP83Rl&ajax=1&cachestop="+str(random.random()))
random.random() is a random no., between 0 & 1
You'll get the captcha Image.
 
Use this URL format (replace the obvious vars) to get an xml response:
Code:
http://api.filesonic.com/link?method=getDownloadLink&u=EMAIL&p=PASSWORD&ids=FILESONICID&format=xml

Replace 'format=xml' with 'format=json' to get a response in json.

Then, just use php's json_decode function to decode the response and extract the links using the appropriate array hierarchy.
 
Use this URL format (replace the obvious vars) to get an xml response:
Code:
http://api.filesonic.com/link?method=getDownloadLink&u=EMAIL&p=PASSWORD&ids=FILESONICID&format=xml
Replace 'format=xml' with 'format=json' to get a response in json.

Then, just use php's json_decode function to decode the response and extract the links using the appropriate array hierarchy.

Yea that seems to be the easiest solution for ricardo.

Do you know of a way to report the current upload or download speed of curl through php? I'd rather use curl for downloading and uploading, but with no progress I'd have to use the example from RL of sending chunks through a socket?
 
I don't know how it's done in PHP, but
in Python, there's a function called urllib.urlretrieve()
It takes an argument called reporthook, which takes a hook function.
this hook function takes three arguments
count of blocks, the size of the block, total size of all the blocks(filesize)
in bytes.
Source: docs
It's tailored to do what you need.


EDIT: Please dont highjack this thread. Instead make a new thread, for your queries.

EDIT_AGAIN: Maybe you can use a subprocess, to download the file in python, and do the rest with PHP.
 
Well, I've thought about a better solution for the progress bar. The thread will be updated with the source for the same. And I don't mind the inputs from others as long as it helps the users with the source ^_^ .

btw, you'll need PHP 5.3.0 for cURL Progress monitoring
 
Last edited:
I know that, I'm trying to make one for downloading, could you give a help?

Follow the code for filesonic:
Code:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.filesonic.com/user/login");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "email=xxxxxxxxx&redirect=%2F&password=xxxxxxxx&rememberMe=1");
$output = curl_exec($ch);
curl_close($ch);
echo $output;

The problem is not logging in. Any idea? :'(
use this
"email=$fsouser&password=$fsopass&controls[submit]=/user/login";
and store the cookies
if you need more help pm me.
 
I've finished testing the code gunda kindly shared, but I have a weird experience. As I dont have php 5.3 I've measured upload speed by benchmark filesize/(end time - start time). I'm only getting around 1-2MB/s upload vs FTP @ 10-40MB/s.

Anyone know why this is?
 
nice.
one question, filesonic is the unique that provides its api?
the rest also do the same?
 
Last edited:
Status
Not open for further replies.
Back
Top