• 2022-09-04被罚款200元记6分.
  • 特么的.电脑风扇坏了.快递还全部停发.太难了...求求了.疫情赶紧走吧.
  • 难啊难!要钱难!
  • 更新到WordPress5.6啦
  • 有点伤心了,今年净遇到王某海这种人.
  • 难啊难...
  • 七牛的JS SDK 的文档真坑啊.
  • 蓝奏云分享部分地区无法访问需手动修改www.lanzous.com变为:www.lanzoux.com
  • 好气啊~原来使用的CDN服务商莫名其妙的给我服务取消了~
  • 遇见一个沙雕汽车人.

京东图床上传接口 PHP源码

PHP KIENG 6年前 (2019-01-23) 193728次浏览 已收录 1个吐槽 扫描二维码

哪里的图床最稳定呢。

新浪,京东,淘宝,百度,搜狗。360

不过一般来说 还是京东,淘宝的比较稳定!

下面是京东图床PHP 上传代码

  1. <?php
  2. /*
  3. * 京东图床 PHP 代码
  4. * KIENG 博客
  5. * http://blog.kieng.cn
  6. */
  7.  
  8. if (class_exists('CURLFile')) { // php 5.5
  9. $post['file'] = new \CURLFile(realpath($_FILES['Filedata']['tmp_name']));
  10. } else {
  11. $post['file'] = '@'.realpath($_FILES['Filedata']['tmp_name']);
  12. }
  13. $rel = get_curl('https://search.jd.com/image?op=upload',$post);
  14. preg_match('/callback(?:\(\")(.*)(?:\"\))/i',$rel,$matches);
  15. if (!$matches[1]) {
  16. exit('图片上传失败!');
  17. }
  18.  
  19. $arr = array(
  20. 'code' => 200,
  21. 'imgurl'=> 'https://img'.rand(10,14).'.360buyimg.com/uba/'.$matches[1]
  22. );
  23. exit(json_encode($arr));
  24. function get_curl($url, $post=0, $referer=0, $cookie=0, $header=0, $ua=0, $nobaody=0){
  25. $ch = curl_init();
  26. curl_setopt($ch, CURLOPT_URL, $url);
  27. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  28. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  29. $httpheader[] = "Accept:application/json";
  30. $httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
  31. $httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
  32. $httpheader[] = "Connection:close";
  33. curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
  34. if ($post) {
  35. curl_setopt($ch, CURLOPT_POST, 1);
  36. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  37. }
  38. if ($header) {
  39. curl_setopt($ch, CURLOPT_HEADER, true);
  40. }
  41. if ($cookie) {
  42. curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  43. }
  44. if($referer){
  45. if($referer==1){
  46. curl_setopt($ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter?g_f=');
  47. }else{
  48. curl_setopt($ch, CURLOPT_REFERER, $referer);
  49. }
  50. }
  51. if ($ua) {
  52. curl_setopt($ch, CURLOPT_USERAGENT, $ua);
  53. }
  54. else {
  55. curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; U; Android 4.0.4; es-mx; HTC_One_X Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0");
  56. }
  57. if ($nobaody) {
  58. curl_setopt($ch, CURLOPT_NOBODY, 1);
  59. }
  60. curl_setopt($ch, CURLOPT_TIMEOUT, 3);
  61. curl_setopt($ch, CURLOPT_ENCODING, "gzip");
  62. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  63. $ret = curl_exec($ch);
  64. curl_close($ch);
  65. return $ret;
  66. }

KIENG.CN , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA 4.0协议进行授权
转载请注明出处:京东图床上传接口 PHP 源码
本文章链接:https://blog.kieng.cn/449.html
喜欢 (6)
KIENG
关于作者:
一个热衷网络的Man
发表我的评论
取消评论
表情 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 快速获取昵称
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
(1)个小伙伴在吐槽
  1. 京東的接口失效了,請問能否告知京東和QQ的新接口?
    SCV | 中国河北廊坊市 联通2021-03-01 20:14 回复 Windows 10 | Firefox浏览器 56.0