Initial commit
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\utility\imghosting\api;
|
||||
|
||||
use Exception;
|
||||
use plugin\utility\imghosting\api;
|
||||
|
||||
class cdn58 implements api
|
||||
{
|
||||
public function upload($filepath, $filename){
|
||||
$url = 'https://upload.58cdn.com.cn/json';
|
||||
$referer = 'https://ai.58.com/pc/';
|
||||
$imgdata = base64_encode(file_get_contents($filepath));
|
||||
$params = [
|
||||
'Pic-Data' => $imgdata,
|
||||
'Pic-Encoding' => 'base64',
|
||||
'Pic-Path' => '/nowater/webim/big/',
|
||||
'Pic-Size' => '0*0'
|
||||
];
|
||||
$data = get_curl($url,json_encode($params),$referer,0,0,0,0,['application/json']);
|
||||
if(strpos($data, 'n_v2')!==false){
|
||||
$imgurl = 'https://pic'.rand(1,8).'.58cdn.com.cn/nowater/webim/big/'.$data;
|
||||
return ['url'=>$imgurl];
|
||||
}else{
|
||||
throw new Exception('上传失败!接口错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\utility\imghosting\api;
|
||||
|
||||
use Exception;
|
||||
use plugin\utility\imghosting\api;
|
||||
|
||||
class dianping implements api
|
||||
{
|
||||
public function upload($filepath, $filename){
|
||||
$url = 'https://kf.dianping.com/api/file/burstUploadFile';
|
||||
$file = new \CURLFile($filepath);
|
||||
$file->setPostFilename($filename);
|
||||
$param = [
|
||||
'files' => $file,
|
||||
'fileName' => $filename,
|
||||
'part' => '0',
|
||||
'partSize' => '1',
|
||||
'fileID' => time().rand(111,999)
|
||||
];
|
||||
$header = [
|
||||
'CSC-VisitId: '.$this->getvisitid()
|
||||
];
|
||||
$data = get_curl($url,$param,'https://h5.dianping.com/',0,0,0,0,$header);
|
||||
$arr = json_decode($data,true);
|
||||
if(isset($arr['code']) && $arr['code'] == 200){
|
||||
$picurl = str_replace('http://','https://',$arr['data']['uploadPath']);
|
||||
return ['url'=>$picurl];
|
||||
}elseif(isset($arr['errMsg'])){
|
||||
throw new Exception('上传失败!'.$arr['errMsg']);
|
||||
}else{
|
||||
throw new Exception('上传失败!接口错误');
|
||||
}
|
||||
}
|
||||
|
||||
private function getvisitid(){
|
||||
$visitid = cache('dianping_visitid');
|
||||
if($visitid) return $visitid;
|
||||
$url = 'https://kf.dianping.com/csCenter/access/dealOrder_Help_DP_PC';
|
||||
$url = $this->get_location_url($url);
|
||||
if($url){
|
||||
$visitid = getSubstr($url, 'visitId=', '&');
|
||||
if($visitid){
|
||||
cache('dianping_visitid', $visitid, 86400);
|
||||
return $visitid;
|
||||
}
|
||||
}
|
||||
throw new Exception('上传失败!获取visitId异常');
|
||||
}
|
||||
|
||||
private function get_location_url($url){
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36");
|
||||
curl_exec($ch);
|
||||
$final_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
|
||||
curl_close($ch);
|
||||
return $final_url;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\utility\imghosting\api;
|
||||
|
||||
use Exception;
|
||||
use plugin\utility\imghosting\api;
|
||||
|
||||
class imgdd implements api
|
||||
{
|
||||
public function upload($filepath, $filename){
|
||||
$url = 'https://imgdd.com/api/v1/upload';
|
||||
$referer = 'https://imgdd.com/';
|
||||
$file = new \CURLFile($filepath);
|
||||
$file->setPostFilename($filename);
|
||||
$param = [
|
||||
'image' => $file,
|
||||
];
|
||||
$data = get_curl($url,$param,$referer);
|
||||
$arr = json_decode($data,true);
|
||||
if(isset($arr['url'])){
|
||||
return ['url'=>$arr['url']];
|
||||
}elseif(isset($arr['message'])){
|
||||
throw new Exception('上传失败请重试('.$arr['message'].')');
|
||||
}else{
|
||||
throw new Exception('上传失败!接口错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\utility\imghosting\api;
|
||||
|
||||
use Exception;
|
||||
use plugin\utility\imghosting\api;
|
||||
|
||||
class netease implements api
|
||||
{
|
||||
public function upload($filepath, $filename){
|
||||
$url = 'http://upload.buzz.163.com/picupload';
|
||||
$file = new \CURLFile($filepath);
|
||||
$file->setPostFilename($filename);
|
||||
$param = [
|
||||
'file' => $file,
|
||||
'from' => 'neteasecode_mp',
|
||||
];
|
||||
$data = get_curl($url,$param,$url);
|
||||
$arr = json_decode($data,true);
|
||||
if(isset($arr['code']) && $arr['code']==200){
|
||||
return ['url'=>str_replace('http://','https://',$arr['data']['url'])];
|
||||
}elseif(isset($arr['msg'])){
|
||||
throw new Exception('上传失败请重试('.$arr['msg'].')');
|
||||
}else{
|
||||
throw new Exception('上传失败!接口错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\utility\imghosting\api;
|
||||
|
||||
use Exception;
|
||||
use plugin\utility\imghosting\api;
|
||||
|
||||
class oppo implements api
|
||||
{
|
||||
public function upload($filepath, $filename){
|
||||
$url = 'https://api.open.oppomobile.com/api/utility/upload';
|
||||
$file = new \CURLFile($filepath);
|
||||
$file->setPostFilename($filename);
|
||||
$param = [
|
||||
'file' => $file,
|
||||
'type' => 'feedback',
|
||||
];
|
||||
$data = get_curl($url,$param,$url);
|
||||
$arr = json_decode($data,true);
|
||||
if(isset($arr['errno']) && $arr['errno']==0){
|
||||
return ['url'=>str_replace('store2.heytapimage.com', 'store.heytapimage.com', $arr['data']['url'])];
|
||||
}elseif(isset($arr['data']['message'])){
|
||||
throw new Exception('上传失败请重试('.$arr['data']['message'].')');
|
||||
}else{
|
||||
throw new Exception('上传失败!接口错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\utility\imghosting\api;
|
||||
|
||||
use Exception;
|
||||
use plugin\utility\imghosting\api;
|
||||
use think\helper\Str;
|
||||
|
||||
class pngcm implements api
|
||||
{
|
||||
public function upload($filepath, $filename){
|
||||
$url = 'https://png.cm/app/upload.php';
|
||||
$file = new \CURLFile($filepath);
|
||||
$file->setPostFilename($filename);
|
||||
$param = [
|
||||
'name' => $filename,
|
||||
'uuid' => 'o_'.Str::random(27),
|
||||
'sign' => time(),
|
||||
'file' => $file,
|
||||
];
|
||||
$data = get_curl($url,$param,'https://png.cm/');
|
||||
$arr = json_decode($data,true);
|
||||
if(isset($arr['code']) && $arr['code']==200){
|
||||
return ['url'=>$arr['url']];
|
||||
}elseif(isset($arr['message'])){
|
||||
throw new Exception('上传失败请重试('.$arr['message'].')');
|
||||
}else{
|
||||
throw new Exception('上传失败!接口错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\utility\imghosting\api;
|
||||
|
||||
use Exception;
|
||||
use plugin\utility\imghosting\api;
|
||||
|
||||
class vipkid implements api
|
||||
{
|
||||
public function upload($filepath, $filename){
|
||||
$url = 'https://www.vipkid.com/rest/gw/api/upload/vos';
|
||||
$file = new \CURLFile($filepath);
|
||||
$file->setPostFilename($filename);
|
||||
$param = [
|
||||
'file' => $file,
|
||||
'uploadType' => 'IM'
|
||||
];
|
||||
$data = get_curl($url,$param,$url,0,0,0,0,['vk-cr-code: kr']);
|
||||
$arr = json_decode($data,true);
|
||||
if(isset($arr['code']) && $arr['code']==200){
|
||||
return ['url'=>$arr['data']['url']];
|
||||
}elseif(isset($arr['msg'])){
|
||||
throw new Exception('上传失败请重试('.$arr['msg'].')');
|
||||
}else{
|
||||
throw new Exception('上传失败!接口错误');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user