全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 810|回复: 5

PHP京东图床上传接口源码

[复制链接]
发表于 2019-1-28 14:53:38 | 显示全部楼层 |阅读模式
<?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, 'http://m.qzone.com/infocenter?g_f=');
}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;
}
发表于 2019-1-28 14:55:28 | 显示全部楼层
没看懂。字数补丁
发表于 2019-1-28 15:23:39 | 显示全部楼层
搞点大姐姐上传 然后举报走一波,会有奖金拿吗
 楼主| 发表于 2019-1-28 15:24:50 | 显示全部楼层
ohmyga 发表于 2019-1-28 15:23
搞点大姐姐上传 然后举报走一波,会有奖金拿吗

发表于 2019-1-28 15:30:44 | 显示全部楼层
{"code":200,"imgurl":"https:\/\/img11.360buyimg.com\/uba\/ERROR.UPLOAD_FORMAT"}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-19 17:17 , Processed in 0.100416 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表