注册 登录
n/program · 2024-05-11 · 1909 次浏览
u/luckycxy白银
n/programu/luckycxy · 2024-05-11

京东图床上传api接口源码

京东首页有个以图搜商品的功能,
在这里上传图片后,图片会被储存到京东的 jfs 里,同时返回 jfs key,
然后我们可以利用商品图片的链接构造进行访问。
支持格式 jpg 、 png 、 bmp
支持大小 5MB
CDN 节点 国内网宿,国外 AKAMAI
img10.360buyimg.com
img10.joybuy.com
优点 大厂稳定,连接速度快,自身量那么多没空删你

回复查看PHP源代码
~~~~
<? php
if (class_exists('CURLFile')) { // php 5.5
$post['file'] = new CURLFile(realpath($*~~~~FILES['Filedata']['tmp_name']));
} else {
$post['file'] = '@'.realpath($
FILES['Filedata']['tmp_name']);
}
$rel = get_curl('https://search.jd.com/image?op=upload', $post);
preg_match('/callback(?:(")(.
)(?:"))/i', $rel, $matches);
if (!$matches[1]) {
exit('图片上传失败!');
}
$arr = array(
'code' => 200,
'imgurl' => 'https://img'.rand(10, 14).
'.360buyimg.com/uba/'.$matches[1]
);
exit(json_encode($arr));

function get_curl($url, $post = 0, $referer = 0, $cookie = 0, $header = 0, $ua = 0, $nobaody = 0) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept:application/json";
$httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
$httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
$httpheader[] = "Connection:close";
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
if ($post) {
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
if ($header) {
curl_setopt($ch, CURLOPT_HEADER, true);
}
if ($cookie) {
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
if ($referer) {
if ($referer == 1) {
curl_setopt($ch, CURLOPT_REFERER, 'https://zerossl.pages.dev/');
} else {
curl_setopt($ch, CURLOPT_REFERER, $referer);
}
}
if ($ua) {
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
} else {
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");
}
if ($nobaody) {
curl_setopt($ch, CURLOPT_NOBODY, 1);
}
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($ch);
curl_close($ch);
return $ret;
}


6
129
登录后参与讨论。
海外原生IP VPS,稳定访问全球网络

还在为IP不纯、平台风控、频繁验证而烦恼? 丽萨主机海外原生IP VPS,双ISP住宅IP,覆盖美国、香港、日本、新加坡、台湾、德国、越南、英国等热门地区,适合跨境电商、社媒运营、AI工具、流媒体及海外业务使用。

lisahost.com 了解更多

129 条回复

排序
  1. mlw10086 白银 2024-05-11 #2

    666

    0
  2. James 💯 传奇 MANAGER 2024-05-11 #3

    mjj真是人才,哪里都能找到口子。

    1
  3. Outburst 白银 2024-05-11 #4

    能保存多久呢

    0
  4. l888 白银 2024-05-11 #5

    真牛来看看

    1
  5. sakujo 荣誉会员 钻石 2024-05-12 #6

    谁要学而思的?

    0
  6. freepayzz 钻石 2024-05-12 已编辑 #7

    还不如这个

    https://imgcdn.bolgk.eu.org

    https://imgcdn.bolgk.eu.org/file/49cb24bfe9d84247222ef.png

    修改过代码

    ```
    <?php
    if (class_exists('CURLFile')) {
    $post['file'] = new CURLFile(realpath($FILES['Filedata']['tmp_name']));
    } else {
    $post['file'] = '@' . realpath($FILES['Filedata']['tmp_name']);
    }
    $rel = get_curl('https://search.jd.com/image?op=upload', $post);
    preg_match('/callback(?:("))(.*)(?:")/i', $rel, $matches);
    if (!$matches[1]) {
    exit('图片上传失败!');
    }
    $arr = array(
    'code' => 200,
    'imgurl' => 'https://img' . rand(10, 14) . '.360buyimg.com/uba/' . $matches[1]
    );
    exit(json_encode($arr));

    function get_curl($url, $post = null, $referer = null, $cookie = null, $header = null, $ua = null, $nobody = null) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    $httpheader = array(
    "Accept:application/json",
    "Accept-Encoding:gzip,deflate,sdch",
    "Accept-Language:zh-CN,zh;q=0.8",
    "Connection:close"
    );
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
    if ($post !== null) {
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    }
    if ($header !== null) {
    curl_setopt($ch, CURLOPT_HEADER, true);
    }
    if ($cookie !== null) {
    curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    }
    if ($referer !== null) {
    curl_setopt($ch, CURLOPT_REFERER, $referer);
    }
    if ($ua !== null) {
    curl_setopt($ch, CURLOPT_USERAGENT, $ua);
    } else {
    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");
    }
    if ($nobody !== null) {
    curl_setopt($ch, CURLOPT_NOBODY, true);
    }
    curl_setopt($ch, CURLOPT_TIMEOUT, 3);
    curl_setopt($ch, CURLOPT_ENCODING, "gzip");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $ret = curl_exec($ch);
    curl_close($ch);
    return $ret;
    }
    ?>
    ```

    1
  7. wangnet 白银 2024-05-12 #8

    为什么隐藏啊啊啊

    0
  8. YUNFU 白银 2024-05-12 #9

    666666

    0
  9. LjyLab 白银 2024-05-12 #10

    wc 6666

    0
  10. drk 白银 2024-05-12 #11

    才华666

    0
  11. bysunney 白银 2024-05-12 #12

    感谢分享

    0
  12. iStarCc 白银 2024-05-12 #13

    666,看看是怎么样

    0
  13. jzhfg 富可敌国 王者 MANAGER 2024-05-13 #14

    真的是玩的明明白白得,感谢分享

    0
  14. 0x0208v0 白银 2024-05-13 #15

    有没有Python版本的。。。PHP太难了,看不懂啊。。。

    0
  15. heiyu 🌩 钻石 2 YEARS 2024-05-13 #16

    这个牛

    0
  16. zxz 白银 不离不弃 2024-05-13 #17

    这个牛

    0
  17. dokke 🐸荣誉会员 钻石 2024-05-13 #18

    奥利给

    0
  18. zxz 白银 不离不弃 2024-05-13 #19

    测试后没用

    0
  19. jzhfg 富可敌国 王者 MANAGER 2024-05-14 #20

    @"上官的的"#p27760 你测试的是他给的网址吗?那天我用的可以那就是被他停了。

    0
  20. keike 白银 2024-05-14 #21

    真的是个人才,这都能找到

    0
  21. jzhfg 富可敌国 王者 MANAGER 2024-05-14 #22

    @"[未知用户]"#p27760 你试过他给的代码吗?

    0
  22. dynui 白银 2024-05-14 #23

    试试看

    0
  23. uiloog 白银 2024-06-05 #24

    我看看

    0
  24. rullandy 白银 2024-06-05 #25

    再次膜拜技术大佬

    0
  25. okfree 白银 2024-06-05 #26

    感谢感谢

    0
  26. ferygod 白银 不离不弃 2024-06-05 #27

    这个用到自己的网站上 刑吗?:xhj01:

    0
  27. ldd1244 白银 2024-06-05 #28

    666666666666666

    0
  28. zhojin 铂金 2024-06-08 #29

    @"luckycxy"#p27203 :ac01:

    0
  29. zhojin 铂金 2024-06-08 #30

    666

    0