Results 1 to 3 of 3
-
12th Apr 2012, 07:43 AM #1OPMemberWebsite's:
UmNotaBlogger.comMediaFire API: want to sort...
Hello again,
I am using MediaFire's API to share my stuff... I just post the folder link and the files are automatically parsed... and this is the code snippet that I use (including an example):
PHP Code:<?php
$loadxml_folder_info = simplexml_load_file('http://www.mediafire.com/api/folder/get_info.php?folder_key=wl7j50kmccaci');
$max = $loadxml_folder_info->folder_info->file_count;
$output = '';
for ($i = 0; $i < $max; $i++) {
$mf_url_link = 'http://www.mediafire.com/?'.$loadxml_folder_info->folder_info->files->file[$i]->quickkey;
$mf_file_name = $loadxml_folder_info->folder_info->files->file[$i]->filename;
$output .= '<a href="'.$mf_url_link.'" target="_blank" class="downloadBtn"><span><strong>'.$mf_file_name.'</strong></span></a><br />';
}
echo $output;
?>Mr. Goodie2Shoes Reviewed by Mr. Goodie2Shoes on . MediaFire API: want to sort... Hello again, I am using MediaFire's API to share my stuff... I just post the folder link and the files are automatically parsed... and this is the code snippet that I use (including an example): <?php $loadxml_folder_info = simplexml_load_file('http://www.mediafire.com/api/folder/get_info.php?folder_key=wl7j50kmccaci'); $max = $loadxml_folder_info->folder_info->file_count; $output = ''; for ($i = 0; $i < $max; $i++) { $mf_url_link = Rating: 5
-
12th Apr 2012, 09:04 AM #2MemberWebsite's:
wscripts.net damnlolscript.com lulzjet.comHere:
PHP Code:<?php
function sortmulti ($array, $index, $order, $natsort=FALSE, $case_sensitive=FALSE) {
if(is_array($array) && count($array)>0) {
foreach(array_keys($array) as $key)
$temp[$key]=$array[$key][$index];
if(!$natsort) {
if ($order=='asc')
asort($temp);
else
arsort($temp);
}
else
{
if ($case_sensitive===true)
natsort($temp);
else
natcasesort($temp);
if($order!='asc')
$temp=array_reverse($temp,TRUE);
}
foreach(array_keys($temp) as $key)
if (is_numeric($key))
$sorted[]=$array[$key];
else
$sorted[$key]=$array[$key];
return $sorted;
}
return $sorted;
}
$loadxml_folder_info = simplexml_load_file('http://www.mediafire.com/api/folder/get_info.php?folder_key=wl7j50kmccaci');
$max = $loadxml_folder_info->folder_info->file_count;
$output = '';
for ($i = 0; $i < $max; $i++) {
$mf_url_link = 'http://www.mediafire.com/?'.$loadxml_folder_info->folder_info->files->file[$i]->quickkey;
$mf_file_name = $loadxml_folder_info->folder_info->files->file[$i]->filename;
$links[$i]['url'] = $mf_url_link;
$links[$i]['filename'] = $mf_file_name;
}
$links = sortmulti($links,'filename','asc',true,true);
foreach($links as $link) $output .= '<a href="'.$link['url'].'" target="_blank" class="downloadBtn"><span><strong>'.$link['filename'].'</strong></span></a><br />';
echo $output;
?>
-
12th Apr 2012, 11:00 AM #3OPMemberWebsite's:
UmNotaBlogger.comawesome! thanks!
I found another way myself:
PHP Code:<?php
function sortByOneKey(array $array, $key, $asc = true) {
$result = array();
$values = array();
foreach ($array as $id => $value) {
$values[$id] = isset($value[$key]) ? $value[$key] : '';
}
if ($asc) {
asort($values);
}
else {
arsort($values);
}
foreach ($values as $key => $value) {
$result[$key] = $array[$key];
}
return $result;
}
$loadxml_folder_info = simplexml_load_file('http://www.mediafire.com/api/folder/get_info.php?folder_key=wl7j50kmccaci');
$max = $loadxml_folder_info->folder_info->file_count;
$output = '';
$array = array();
for ($i = 0; $i < $max; $i++) {
foreach($loadxml_folder_info->folder_info->files->file[$i]->quickkey as $mf_quickkey){
$subarray = array();
$subarray['key'] = (string)$loadxml_folder_info->folder_info->files->file[$i]->quickkey;
$subarray['name'] = (string)$loadxml_folder_info->folder_info->files->file[$i]->filename;
}
$array[] = $subarray;
}
$sortedByNameAsc = sortByOneKey($array, 'name');
?>
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
LulzImg API (sort of) Upload Example
By Lifetalk in forum Web Development AreaReplies: 4Last Post: 10th Dec 2011, 02:59 PM -
Sort Thread By...
By itsHERO in forum vBulletinReplies: 1Last Post: 20th Oct 2011, 05:47 PM -
How to create some sort of database? (Not SQL or something)
By Dark-BlaZe in forum vBulletinReplies: 2Last Post: 21st Jul 2010, 08:02 PM -
How to sort MegaUpload links with RapidLeech?
By MadK in forum Technical Help Desk SupportReplies: 10Last Post: 27th May 2010, 08:39 AM -
[phpBB2] How to sort this?
By pi0tr3k in forum phpBBReplies: 8Last Post: 2nd Apr 2010, 03:24 PM
themaPoster - post to forums and...
Version 5.22 released. Open older version (or...