提交 d8b00646 编写于 作者: 李光春's avatar 李光春

- update service taobao

上级 26794add
......@@ -19,11 +19,11 @@ namespace DtApp\ThinkLibrary\exception;
use Exception;
/**
* 淘宝错误处理
* 淘宝错误处理
* Class TaoBaoKeException
* @package DtApp\ThinkLibrary\exception
*/
class TaoBaoKeException extends Exception
class TaoBaoException extends Exception
{
public function errorMessage()
{
......
......@@ -17,7 +17,7 @@
namespace DtApp\ThinkLibrary\service\Curl;
use DtApp\ThinkLibrary\exception\CurlException;
use DtApp\ThinkLibrary\exception\TaoBaoKeException;
use DtApp\ThinkLibrary\exception\TaoBaoException;
use DtApp\ThinkLibrary\Service;
/**
......@@ -139,13 +139,13 @@ class TaoBaoKeService extends Service
* 组参
* @param array $arr
* @return $this
* @throws TaoBaoKeException
* @throws TaoBaoException
*/
public function data(array $arr)
{
$this->app_key = empty($this->app_key) ? config('dtapp.taobao.tbk.app_key') : $this->app_key;
if (empty($this->app_key)) throw new TaoBaoKeException('请检查app_key参数');
if (empty($this->method)) throw new TaoBaoKeException('请检查method参数');
if (empty($this->app_key)) throw new TaoBaoException('请检查app_key参数');
if (empty($this->method)) throw new TaoBaoException('请检查method参数');
$arr['app_key'] = $this->app_key;
$arr['method'] = $this->method;
......@@ -162,13 +162,13 @@ class TaoBaoKeService extends Service
* @param string $value
* @param string $name
* @return $this
* @throws TaoBaoKeException
* @throws TaoBaoException
*/
public function datas(string $value, string $name = "requests")
{
$this->app_key = empty($this->app_key) ? config('dtapp.taobao.tbk.app_key') : $this->app_key;
if (empty($this->app_key)) throw new TaoBaoKeException('请检查app_key参数');
if (empty($this->method)) throw new TaoBaoKeException('请检查method参数');
if (empty($this->app_key)) throw new TaoBaoException('请检查app_key参数');
if (empty($this->method)) throw new TaoBaoException('请检查method参数');
$arr = [];
$arr['app_key'] = $this->app_key;
......@@ -184,7 +184,7 @@ class TaoBaoKeService extends Service
/**
* 网络请求
* @throws TaoBaoKeException
* @throws TaoBaoException
*/
private function http()
{
......@@ -204,7 +204,7 @@ class TaoBaoKeService extends Service
/**
* 返回数组数据
* @return array|mixed
* @throws CurlException|TaoBaoKeException
* @throws CurlException|TaoBaoException
*/
public function toArray()
{
......@@ -220,7 +220,7 @@ class TaoBaoKeService extends Service
/**
* 返回Xml数据
* @return mixed
* @throws CurlException|TaoBaoKeException
* @throws CurlException|TaoBaoException
*/
public function toXml()
{
......@@ -234,12 +234,12 @@ class TaoBaoKeService extends Service
/**
* 签名
* @return string
* @throws TaoBaoKeException
* @throws TaoBaoException
*/
private function createSign()
{
$this->app_secret = empty($this->app_secret) ? config('dtapp.taobao.tbk.app_secret') : $this->app_secret;
if (empty($this->app_secret)) throw new TaoBaoKeException('请检查app_secret参数');
if (empty($this->app_secret)) throw new TaoBaoException('请检查app_secret参数');
$sign = $this->app_secret;
ksort($this->param);
......
......@@ -17,9 +17,8 @@
namespace DtApp\ThinkLibrary\service\TaoBao;
use DtApp\ThinkLibrary\exception\CurlException;
use DtApp\ThinkLibrary\exception\TaoBaoKeException;
use DtApp\ThinkLibrary\exception\TaoBaoException;
use DtApp\ThinkLibrary\Service;
use DtApp\ThinkLibrary\service\Curl\TaoBaoKeService;
/**
* 淘宝客
......@@ -103,17 +102,6 @@ class TbkService extends Service
return $this;
}
/**
* API接口名称
* @param string $method
* @return $this
*/
public function method(string $method)
{
$this->method = $method;
return $this;
}
/**
* 应用AppSecret
* @param string $appSecret
......@@ -158,17 +146,327 @@ class TbkService extends Service
return $this;
}
/**
* 订单查询 - 淘宝客-推广者-维权退款订单查询
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=40173&docType=2
* @return array|mixed
*/
public function relationRefund()
{
$this->method = 'taobao.tbk.relation.refund';
return $this;
}
/**
* 处罚订单 - 淘宝客-推广者-处罚订单查询
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=42050&docType=2
* @return array|mixed
*/
public function dgPunishOrderGet()
{
$this->method = 'taobao.tbk.dg.punish.order.get';
return $this;
}
/**
* 拉新订单&效果 - 淘宝客-推广者-新用户订单明细查询
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=33892&docType=2
* @return array|mixed
*/
public function DgNewUserOrderGet()
{
$this->method = 'taobao.tbk.dg.newuser.order.get';
return $this;
}
/**
* 拉新订单&效果 - 淘宝客-推广者-拉新活动对应数据查询
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=36836&docType=2
* @return array|mixed
*/
public function dgNewUserOrderSum()
{
$this->method = 'taobao.tbk.dg.newuser.order.sum';
return $this;
}
/**
* 超级红包发放个数 - 淘宝客-推广者-查询超级红包发放个数
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=47593&docType=2
* @return array|mixed
*/
public function dgVegasSendReport()
{
$this->method = 'taobao.tbk.dg.vegas.send.report';
return $this;
}
/**
* 活动转链(更新版) - 淘宝客-推广者-官方活动信息获取
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=48340&docType=2
* @return array|mixed
*/
public function activityInfoGet()
{
$this->method = 'taobao.tbk.activity.info.get';
return $this;
}
/**
* 活动转链 - 淘宝客-推广者-官方活动转链
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=41918&docType=2
* @return array|mixed
*/
public function activityLinkGet()
{
$this->method = 'taobao.tbk.activitylink.get';
return $this;
}
/**
* 淘口令 - 淘宝客-公用-淘口令生成
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=31127&docType=2
* @return array|mixed
* @throws TaoBaoException
*/
public function tpWdCreate()
{
if (isset($this->param['text'])) if (strlen($this->param['text']) < 5) throw new TaoBaoException('请检查text参数长度');
$this->method = 'taobao.tbk.tpwd.create';
return $this;
}
/**
* 长短链 - 淘宝客-公用-长链转短链
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=27832&docType=2
* @return array|mixed
*/
public function spreadGet()
{
$this->method = 'taobao.tbk.spread.get';
return $this;
}
/**
* 聚划算商品搜索接口
* https://open.taobao.com/api.htm?docId=28762&docType=2&scopeId=16517
* @return array|mixed
*/
public function itemsSearch()
{
$this->method = 'taobao.ju.items.search';
return $this;
}
/**
* 淘抢购api
* https://open.taobao.com/api.htm?docId=27543&docType=2&scopeId=16517
* @return array|mixed
*/
public function juTqgGet()
{
if (!isset($this->param['fields'])) $this->param['fields'] = "click_url,pic_url,reserve_price,zk_final_price,total_amount,sold_num,title,category_name,start_time,end_time";
$this->method = 'taobao.tbk.ju.tqg.get';
return $this;
}
/**
* 淘礼金 - 淘宝客-推广者-淘礼金创建
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=40173&docType=2
* @return array|mixed
*/
public function dgVegasTljCreate()
{
$this->method = 'taobao.tbk.dg.vegas.tlj.create';
return $this;
}
/**
* 淘礼金 - 淘宝客-推广者-淘礼金发放及使用报表
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=43317&docType=2
* @return array|mixed
*/
public function dgVegasTljInstanceReport()
{
$this->method = 'taobao.tbk.dg.vegas.tlj.instance.report';
return $this;
}
/**
* 私域用户管理 - 淘宝客-公用-私域用户邀请码生成
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=38046&docType=2
* @return array|mixed
*/
public function scInvIteCodeGet()
{
$this->method = 'taobao.tbk.sc.invitecode.get';
return $this;
}
/**
* 私域用户管理 - 淘宝客-公用-私域用户备案信息查询
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=37989&docType=2
* @return array|mixed
*/
public function scPublisherInfoGet()
{
$this->method = 'taobao.tbk.sc.publisher.info.get';
return $this;
}
/**
* 私域用户管理 - 淘宝客-公用-私域用户备案
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.210524ad2gvyOW&docId=37988&docType=2
* @return array|mixed
*/
public function scPublisherInfoSave()
{
$this->method = 'taobao.tbk.sc.publisher.info.save';
return $this;
}
/**
* 商品详情&券详情查询 - 淘宝客-公用-淘宝客商品详情查询(简版)
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.178c24advNRYpp&docId=24518&docType=2
* https://open.alimama.com/#!/function?id=25
* @return array|mixed
*/
public function itemInfoGet()
{
$this->method = 'taobao.tbk.item.info.get';
return $this;
}
/**
* 商品详情&券详情查询 - 淘宝客-公用-阿里妈妈推广券详情查询
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.178c24advNRYpp&docId=31106&docType=2
* https://open.alimama.com/#!/function?id=25
* @return array|mixed
*/
public function couponGet()
{
$this->method = 'taobao.tbk.coupon.get';
return $this;
}
/**
* 商品/店铺搜索 - 淘宝客-推广者-物料搜索
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.178c24advNRYpp&docId=35896&docType=2
* https://open.alimama.com/#!/function?id=27
* @return array|mixed
*/
public function dgMaterialOptional()
{
$this->method = 'taobao.tbk.dg.material.optional';
return $this;
}
/**
* 商品/店铺搜索 - 淘宝客-推广者-店铺搜索
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.178c24advNRYpp&docId=24521&docType=2
* https://open.alimama.com/#!/function?id=27
* @return array|mixed
*/
public function shopGet()
{
if (!isset($this->param['fields'])) $this->param['fields'] = "user_id,shop_title,shop_type,seller_nick,pict_url,shop_url";
$this->method = 'taobao.tbk.shop.get';
return $this;
}
/**
* 商品库/榜单精选 - 淘宝客-推广者-物料精选
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.178c24advNRYpp&docId=33947&docType=2
* http://wsd.591hufu.com/taokelianmeng/424.html
* https://open.alimama.com/#!/function?id=28
* @return array|mixed
*/
public function dgOpTiUsMaterial()
{
$this->method = 'taobao.tbk.dg.optimus.material';
return $this;
}
/**
* 图文内容 - 淘宝客-推广者-图文内容输出
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.178c24advNRYpp&docId=31137&docType=2
* https://open.alimama.com/#!/function?id=30
* @return array|mixed
*/
public function contentGet()
{
$this->method = 'taobao.tbk.content.get';
return $this;
}
/**
* 图文内容 - 淘宝客-推广者-图文内容效果数据
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.178c24advNRYpp&docId=37130&docType=2
* https://open.alimama.com/#!/function?id=30
* @return array|mixed
*/
public function contentEffectGet()
{
$this->method = 'taobao.tbk.content.effect.get';
return $this;
}
/**
* 图文内容 - 淘宝客-推广者-商品出词
* https://open.taobao.com/api.htm?spm=a2e0r.13193907.0.0.178c24advNRYpp&docId=37538&docType=2
* @return array|mixed
*/
public function itemWordGet()
{
$this->method = 'taobao.tbk.item.word.get';
return $this;
}
/**
* 淘宝客-推广者-商品链接转换
* https://open.taobao.com/api.htm?docId=24516&docType=2&scopeId=11653
* @return array|mixed
*/
public function itemConvert()
{
if (!isset($this->param['fields'])) $this->param['fields'] = "num_iid,click_url";
$this->method = 'taobao.tbk.item.convert';
return $this;
}
/**
* 淘宝客-公用-链接解析出商品id
* https://open.taobao.com/api.htm?docId=28156&docType=2
* @return array|mixed
*/
public function itemClickExtract()
{
$this->method = 'taobao.tbk.item.click.extract';
return $this;
}
/**
* 返回Array
* @return array|mixed
* @throws CurlException
* @throws TaoBaoKeException
* @throws TaoBaoException
*/
public function toArray()
{
//首先检测是否支持curl
if (!extension_loaded("curl")) throw new CurlException('请开启curl模块!', E_USER_DEPRECATED);
$this->format = "json";
$this->app_key = empty($this->app_key) ? config('dtapp.taobao.tbk.app_key') : $this->app_key;
if (empty($this->app_key)) throw new TaoBaoException('请检查app_key参数');
if (empty($this->method)) throw new TaoBaoException('请检查method参数');
$this->param['app_key'] = $this->app_key;
$this->param['method'] = $this->method;
$this->param['format'] = $this->format;
$this->param['v'] = $this->v;
$this->param['sign_method'] = $this->sign_method;
$this->param['timestamp'] = date('Y-m-d H:i:s');
$this->http();
if (is_array($this->output)) return $this->output;
if (is_object($this->output)) $this->output = json_encode($this->output);
......@@ -179,7 +477,7 @@ class TbkService extends Service
* 返回Xml
* @return mixed
* @throws CurlException
* @throws TaoBaoKeException
* @throws TaoBaoException
*/
public function toXml()
{
......@@ -192,7 +490,7 @@ class TbkService extends Service
/**
* 网络请求
* @throws TaoBaoKeException
* @throws TaoBaoException
*/
private function http()
{
......@@ -212,12 +510,12 @@ class TbkService extends Service
/**
* 签名
* @return string
* @throws TaoBaoKeException
* @throws TaoBaoException
*/
private function createSign()
{
$this->app_secret = empty($this->app_secret) ? config('dtapp.taobao.tbk.app_secret') : $this->app_secret;
if (empty($this->app_secret)) throw new TaoBaoKeException('请检查app_secret参数');
if (empty($this->app_secret)) throw new TaoBaoException('请检查app_secret参数');
$sign = $this->app_secret;
ksort($this->param);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册