wupload upload plugin asap

Status
Not open for further replies.

jokerhacker

Active Member
415
2010
45
0
hey mates,
i need help coding an upload plugin for wupload, every time i make a call, it gives me HTTP/1.1 411 Length Required

i need help asap,
thanks in advance.
 
18 comments
[strike]Use WUPLOAD API:

You might be having fso with there api, just change the user/pass and link and everything else should be same :)[/strike]

I just did teh homework for you so no need of above:

PHP:
<?php

// Wupload Plugin using there API by Soft2050

$wuuser = 'myusername';
$wupass = 'mypass';

function wuploadup($filename, $username, $password) {

    $geturld = file_get_contents("http://api.wupload.com/upload?method=getUploadUrl&u=$username&p=$password&format=xml");
    
    preg_match('/(http:\/\/.*?format=xml)/i', $geturld, $matches); // Ahh You could make teh regex better but this was one which works fine and was easy too
    
    $upurl = $matches[0];
    
    $post = array('files[]' => "@$filename");
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, trim($upurl));
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $getresult = curl_exec($ch);
    curl_close($ch);
    
    preg_match('/\<url\>(.*?)\<\/url\>/i', $getresult, $matches); // Ahh You could make teh regex better but this was one which works fine and was easy too
    
    $resulturl = $matches[0];
    
    return $resulturl;

}

echo wuploadup( 'myfilelink', $wuuser, $wupass);

?>

I also tested it and it works:

20089185.png
 
Last edited:
shiiiiiiiiiiiiiiiiiit!!!!!! :facepalm:
i'm really grateful for you soft2050, but i didn't notice that you edited your post and i removed this shit from my function
PHP:
curl_setopt($ch, CURLOPT_UPLOAD, true);
and now it works.
your code is really greate
+ i didnt know that i can have an xml reponse :D
+ your regex is good ;)
+rep :p
 
shiiiiiiiiiiiiiiiiiit!!!!!! :facepalm:
i'm really grateful for you soft2050, but i didn't notice that you edited your post and i removed this shit from my function
PHP:
curl_setopt($ch, CURLOPT_UPLOAD, true);
and now it works.
your code is really greate
+ i didnt know that i can have an xml reponse :D
+ your regex is good ;)
+rep :p
As far as I think, its Gunda's code.
 
shiiiiiiiiiiiiiiiiiit!!!!!! :facepalm:
i'm really grateful for you soft2050, but i didn't notice that you edited your post and i removed this shit from my function
PHP:
curl_setopt($ch, CURLOPT_UPLOAD, true);
and now it works.
your code is really greate
+ i didnt know that i can have an xml reponse :D
+ your regex is good ;)
+rep :p

Thank you dude

As far as I think, its Gunda's code.

lol! wat :facepalm:

Gunda never released code for Wupload

He did for filesonic i guess (without api)
 
A JSON response (using php's json_decode) is a cleaner way. In Soft's code, if you use the json response, you'll have one less regex matching to do :)
 
change this line
PHP:
 $resulturl = $matches[0];
to
PHP:
 if($matches)
$resulturl = $matches[0];
else $resulturl = false;
then call it like that
PHP:
$counter = 0;
do {
$counter++;
$link = wuploadup( 'myfilelink', $wuuser, $wupass); }
while ( $link == false and $counter <3);
it will try to upload it, if failed it will repeat, if failed 3 times, it will skip ;)
 
php 5.2
Notice: Undefined offset: 0 in C:\server\www\wu\index.php on line 26

Line 26 with php 5.2
PHP:
25: $getresult = curl_exec($ch);
26:    curl_close($ch);
27:    
28:    preg_match('/\<url\>(.*?)\<\/url\>/i', $getresult, $matches);
---
php 5.3
Notice: Undefined offset: 0 in C:\server\www\wu\index.php on line 29
Line 29 in php 5.3
PHP:
$resulturl = $matches[0];
 
Last edited:
php 5.2
Notice: Undefined offset: 0 in C:\server\www\wu\index.php on line 26

Line 26 with php 5.2
PHP:
25: $getresult = curl_exec($ch);
26:    curl_close($ch);
27:    
28:    preg_match('/\<url\>(.*?)\<\/url\>/i', $getresult, $matches);
---
php 5.3
Notice: Undefined offset: 0 in C:\server\www\wu\index.php on line 29
Line 29 in php 5.3
PHP:
$resulturl = $matches[0];

I guess your account details might be incorrect

Check hows the whole output of the page by printing $getresult then you can either use regex or json_decode as suggested by Lifetalk
 
Status
Not open for further replies.
Back
Top