Home > Backend Development > PHP Tutorial > PHP implements code sharing of direct links to Baidu network disk pictures

PHP implements code sharing of direct links to Baidu network disk pictures

WBOY
Release: 2016-07-25 09:03:44
Original
1370 people have browsed it
  1. require_once('snoopy.class.php');

  2. //http://www.abc.com/bdp.php?shareid=29160&uk=2855065916
  3. $url = 'http://pan.baidu.com/share/link?shareid=' . $_GET['shareid'] . '&uk=' . $_GET['uk'];
  4. $snoopy = new Snoopy();
  5. $snoopy -> read_timeout = 0;
  6. $snoopy -> fetch($url);
  7. $n = $snoopy -> results;
  8. $regex = '/(_.src=")(.+)(";)/';
  9. $match = '';
  10. preg_match($regex, $n, $match);

  11. if(preg_match('/.gif/', $match[2])){

  12. header("Content-type: image/gif");
  13. imagegif(imagecreatefromgif($match[2]));
  14. }elseif(preg_match('/.jpg/', $match[2])){
  15. header("Content-type: image/jpeg");
  16. imagejpeg(imagecreatefromjpeg($match[2]));
  17. }elseif(preg_match('/.png/', $match[2])){
  18. header("Content-type: image/png");
  19. imagepng(imagecreatefrompng($match[2]));
  20. }elseif(preg_match('/.wbmp/', $match[2])){
  21. header("Content-type: image/vnd.wap.wbmp");
  22. imagewbmp(imagecreatefromwbmp($match[2]));
  23. }else{}
  24. ?>

复制代码

snoopy.class.php是一个php类,用来模仿web浏览器的功能,它能完成获取网页内容和发送表单的任务。 这个文件自己搜索下载吧。以上文件需要一个支持PHP的空间。百度网盘上传图片并发布分享,取得分享地址后的 shareid=29160&uk=2855065916 参数。 使用 http://你的域名/bdp.php?shareid=29160&uk=2855065916 得到图片,这个地址可以放在CKEditor图像地址中使用。其它编辑器应该也可以。 网页中直接使用:PHP implements code sharing of direct links to Baidu network disk pictures



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template