Using PHP to realize Baidu network disk picture straight chain code sharing _php Example

Source: Internet
Author: User
Tags php class
First code: Less code
Through regular expression to get the real address of Baidu Network disk, to achieve the effect of direct chain

Save the following code as downbd.php
Copy Code code as follows:

<?php
$canshu =$_server["Query_string"];
if ($canshu = = "")
{
Die ("file does not exist");
}
Else
{
$wangzhi = "Http://pan.baidu.com/share/link?". $canshu;
$file =file_get_contents ($wangzhi);
$pattern = '/a><a class= ' dbtn cancel Singledbtn ' href= (. *?) Id= "Downfilebuttom" >/i ";
Preg_match_all ($pattern, $file, $result);
$tempurl =implode ("", $result [1]);
$FILEURLT =str_replace ("\" "," ", $tempurl);
$fileurl =str_replace ("&", "&", $FILEURLT);
Header ("Location: $fileurl");
}
?>

Call Method:

http://***/downbd.php?shareid=00000&uk=00000
Mainly the shareid=00000&uk=00000 format.

The second type:

Made a small feature, ready to share the pictures in the blog.

Look at the code! Code saved as bdp.php

Copy Code code as follows:

<?php
Require_once (' snoopy.class.php ');
http://www.abc.com/bdp.php?shareid=29160&uk=2855065916
$url = ' http://pan.baidu.com/share/link?shareid= '. $_get[' Shareid ']. ' &uk= '. $_get[' UK '];
$snoopy = new Snoopy ();
$snoopy-> read_timeout = 0;
$snoopy-> Fetch ($URL);
$n = $snoopy-> results;
$regex = '/(_.src= ') (. +) (";)/";
$match = ';
Preg_match ($regex, $n, $match);

if (Preg_match ('/.gif/', $match [2])) {
Header ("Content-type:image/gif");
Imagegif (Imagecreatefromgif ($match [2]));
}elseif (Preg_match ('/.jpg/', $match [2])) {
Header ("Content-type:image/jpeg");
Imagejpeg (Imagecreatefromjpeg ($match [2]));
}elseif (Preg_match ('/.png/', $match [2])) {
Header ("Content-type:image/png");
Imagepng (Imagecreatefrompng ($match [2]));
}elseif (Preg_match ('/.wbmp/', $match [2])) {
Header ("Content-type:image/vnd.wap.wbmp");
Imagewbmp (Imagecreatefromwbmp ($match [2]));
}else{}
?>

Snoopy.class.php is a PHP class that mimics the functionality of a Web browser, which completes the task of getting web content and sending forms. This file can be Baidu. The above file requires a space to support PHP. Baidu Network disk upload pictures and share, get the share address after the shareid=29160&uk=2855065916 parameters.
Use http://your domain name/bdp.php?shareid=29160&uk=2855065916 to get pictures, this address can be used in CKEditor image address. Other editors should also be available.
Web page directly Use

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.