PHP implementation Batch Download Baidu cloud Disk File example sharing _php Tutorial

Source: Internet
Author: User
Baidu Open Cloud phpsdk download Address: http://developer.baidu.com/wiki/index.php?title=%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3%E9%A6%96% E9%a1%b5/web%e5%ba%94%e7%94%a8%e6%8e%a5%e5%85%a5/sdk

Instance code:
Copy CodeThe code is as follows:
/**
* AUTHOR:HANKCS
* date:14-3-29
* Time: 10:29
*/
Ini_set ("Max_execution_time", 36000);
Require_once '. /bcs.class.php ';
Require_once '. /krumo/class.krumo.php ';
$host = ' bcs.duapp.com ';
$ak = ' Your public key ';
$sk = ' your private key ';
$bucket = ' bucket name to download ';
$baidu _bcs = new Baidubcs ($ak, $sk, $host);

$response = Json_decode ($baidu _bcs->list_object ($bucket, Array (' start ' = 0, ' limit ' = ' 1024x768 '),->body);
$downloaded _size = 0;
while ($downloaded _size < $response->object_total)
{
Krumo ($response);
Download them
foreach ($response->object_list as $object)
{
if (! $object->is_dir)
{
Mk_dir ('. '). $object->parent_dir);
$result = $baidu _bcs->get_object ($bucket, $object->object, Array ("Filewriteto" = "."). $object->object));
}
}
$downloaded _size + = count ($response->object_list);
$response = Json_decode ($baidu _bcs->list_object ($bucket, Array (' Start ' = $downloaded _size, ' limit ' = 1024,) )->body);
}

function Mk_dir ($dir, $mode = 0755)
{
if (Is_dir ($dir) | | @mkdir ($DIR, $mode)) return true;
if (!mk_dir (DirName ($dir), $mode)) return false;
Return @mkdir ($dir, $mode);
}

http://www.bkjia.com/PHPjc/751936.html www.bkjia.com true http://www.bkjia.com/PHPjc/751936.html techarticle Baidu Open Cloud phpsdk download Address: http://developer.baidu.com/wiki/index.php?title=%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3%E9%A6 %96%E9%A1%B5/WEB%E5%BA%94%E7%94%A8%E6%8E%A5%E5%85%A5/S ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.