XFileSharing Pro - deurl 1- Page 2

Message
Author
sonny3
Posts: 15
Joined: Apr 20, 2012 8:21 pm

#16 Postby sonny3 » Jul 08, 2012 3:21 pm

randy wrote:can you tell us that we can use it too? like bit.ly and adf.ly? which lines in index we have to change?

I bought a short url script, but I also use adf.ly, but this seems not possible, then I sold the script and now use only adf.ly as you do. thank you

randy
Posts: 321
Joined: Mar 13, 2012 7:00 pm

#17 Postby randy » Jul 08, 2012 3:28 pm

can you tell me how to integrate adf.ly? what needs to be changed in index.cgi?

sonny3
Posts: 15
Joined: Apr 20, 2012 8:21 pm

#18 Postby sonny3 » Jul 08, 2012 3:50 pm

randy wrote:can you tell me how to integrate adf.ly? what needs to be changed in index.cgi?

I still do not work do the other tests and then tell you

randy
Posts: 321
Joined: Mar 13, 2012 7:00 pm

#19 Postby randy » Jul 08, 2012 3:52 pm

ok great! this would be nice! because ad.fly is popular!

trinsic
Posts: 149
Joined: Dec 21, 2009 9:24 am

#20 Postby trinsic » Jul 09, 2012 3:59 am

All the Deurl is done from lines 654 to 672 of index.cgi.

Code: Select all

   if($c->{deurl_site} && $c->{deurl_api_key})
   {
      require LWP::UserAgent;
      my $ua = LWP::UserAgent->new(timeout => 5);
      my $author = $ses->getUser ? $ses->getUser->{usr_login} : '';
      for(@arr)
      {
         my $res = $ua->post("$c->{deurl_site}/",
                             {
                                op  => 'api',
                                api_key => $c->{deurl_api_key},
                                url => $_->{download_link},
                                size => sprintf("%.01f",$_->{file_size2}/1048576),
                                author => $author,
                             }
                            )->content;
         ($_->{deurl}) = $res=~/^OK:(.+)$/;
      }
   }


I'm not even remotely close to an expert in Perl let alone any other language but I found it trivial to change to Bit.ly.

Now I done this in XFS 1.8 so forgive me if it's different in 1.9 or 2.0.

In XFS settings panel put anything in the DeURL url box to activate.

Then replace the above code with this:

Code: Select all

   if($c->{deurl_site})
   {
      require LWP::UserAgent;
      my $ua = LWP::UserAgent->new(timeout => 5);
      for(@arr)
      {
         my $res = $ua->get('http://api.adf.ly/api.php?key=e8b9694d5e5cc8131c40b46db96a518f&uid=2113590&advert_type=int&domain=adf.ly&url='.$_->{download_link});
         ($_->{deurl}) = $res->decoded_content;
      }
   }



You can find all your API details for Adf.ly from: http://adf.ly/tools.php?api

I advise you change the key and uid unless you want me to make money (which I wouldn't mind lol).
advert_type can be int or banner
domain can be adf.ly or q.gs


If you want to create two short URLs for every link just copy the entire deurl block of code and paste it below it so you're repeating it twice.

e.g

Code: Select all

   if($c->{deurl_site} && $c->{deurl_api_key})
   {
      require LWP::UserAgent;
      my $ua = LWP::UserAgent->new(timeout => 5);
      my $author = $ses->getUser ? $ses->getUser->{usr_login} : '';
      for(@arr)
      {
         my $res = $ua->post("$c->{deurl_site}/",
                             {
                                op  => 'api',
                                api_key => $c->{deurl_api_key},
                                url => $_->{download_link},
                                size => sprintf("%.01f",$_->{file_size2}/1048576),
                                author => $author,
                             }
                            )->content;
         ($_->{deurl}) = $res=~/^OK:(.+)$/;
      }
   }
   if($c->{deurl_site} && $c->{deurl_api_key})
   {
      require LWP::UserAgent;
      my $ua = LWP::UserAgent->new(timeout => 5);
      my $author = $ses->getUser ? $ses->getUser->{usr_login} : '';
      for(@arr)
      {
         my $res = $ua->post("$c->{deurl_site}/",
                             {
                                op  => 'api',
                                api_key => $c->{deurl_api_key},
                                url => $_->{download_link},
                                size => sprintf("%.01f",$_->{file_size2}/1048576),
                                author => $author,
                             }
                            )->content;
         ($_->{deurl}) = $res=~/^OK:(.+)$/;
      }
   }


Change

Code: Select all

($_->{deurl}) = $res=~/^OK:(.+)$/;
to

Code: Select all

($_->{deurl2}) = $res=~/^OK:(.+)$/;
in the second block of code you pasted then in your upload_results.html use <TMPL_VAR deurl> and <TMPL_VAR deurl2> to retrieve the short urls.

I'm available for work if you can't get it working.

trinsic
Posts: 149
Joined: Dec 21, 2009 9:24 am

#21 Postby trinsic » Jul 09, 2012 4:12 am

Bit.ly if you wish:

Code: Select all

   if($c->{deurl_site})
   {
      require LWP::UserAgent;
      my $ua = LWP::UserAgent->new(timeout => 5);
      for(@arr)
      {
         my $res = $ua->get('http://api.bit.ly/v3/shorten?login=[login]&apiKey=[api]&format=txt&longUrl='.$_->{download_link});
         ($_->{deurl}) = $res->decoded_content;
      }
   }


Replace [api] with your API key and [login] with your login.
Last edited by trinsic on Jul 09, 2012 5:02 am, edited 1 time in total.

randy
Posts: 321
Joined: Mar 13, 2012 7:00 pm

#22 Postby randy » Jul 09, 2012 4:19 am

first of all thx a lot! I will try it now and let you know here...


Return to “XFileSharing Pro”



Who is online

Users browsing this forum: No registered users and 1 guest