|
@@ -7,6 +7,7 @@ namespace App\Http\Utils\TaoBao;
|
|
|
use App\Exceptions\TaobaoException;
|
|
|
use App\Http\Utils\BaseUtil;
|
|
|
use App\Http\Utils\LoggerFactoryUtil;
|
|
|
+use App\Models\TaobaoPidModel;
|
|
|
use ETaobao\Factory;
|
|
|
/**
|
|
|
* 淘宝联盟工具类
|
|
@@ -32,7 +33,19 @@ class TaobaoLianMengUtil extends BaseUtil
|
|
|
*/
|
|
|
public static function getActivityInfo($adzone_id,$activity_material_id)
|
|
|
{
|
|
|
- $app = self::getApp();
|
|
|
+ //根据pid找到淘宝信息
|
|
|
+ $taobao = TaobaoPidModel::query()
|
|
|
+ ->where("adzone_id",$adzone_id)
|
|
|
+ ->first();
|
|
|
+ $config = [
|
|
|
+ "appkey"=>$taobao["taobao_app_key"],//淘宝客appKey
|
|
|
+ "secretKey"=>$taobao["taobao_app_secret"],//secretKey
|
|
|
+ "format"=>"json",//返回的数据格式
|
|
|
+ "session"=>"",//授权接口(sc类的接口)需要带上
|
|
|
+ "sandbox"=>false,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $app = Factory::tbk($config);
|
|
|
$params = [
|
|
|
"adzone_id"=>$adzone_id,
|
|
|
"activity_material_id"=>$activity_material_id
|
|
@@ -142,10 +155,22 @@ class TaobaoLianMengUtil extends BaseUtil
|
|
|
/**
|
|
|
* 获取淘口令接口
|
|
|
* @param $url string 地址
|
|
|
+ * @param $adzone_id string 推广位
|
|
|
*/
|
|
|
- public static function taokoulingCreate($url)
|
|
|
+ public static function taokoulingCreate($url,$adzone_id)
|
|
|
{
|
|
|
- $app = self::getApp();
|
|
|
+ //根据pid找到淘宝信息
|
|
|
+ $taobao = TaobaoPidModel::query()
|
|
|
+ ->where("adzone_id",$adzone_id)
|
|
|
+ ->first();
|
|
|
+ $config = [
|
|
|
+ "appkey"=>$taobao["taobao_app_key"],//淘宝客appKey
|
|
|
+ "secretKey"=>$taobao["taobao_app_secret"],//secretKey
|
|
|
+ "format"=>"json",//返回的数据格式
|
|
|
+ "session"=>"",//授权接口(sc类的接口)需要带上
|
|
|
+ "sandbox"=>false,
|
|
|
+ ];
|
|
|
+ $app = Factory::tbk($config);
|
|
|
$params = [
|
|
|
"url"=>$url
|
|
|
];
|
|
@@ -160,13 +185,26 @@ class TaobaoLianMengUtil extends BaseUtil
|
|
|
/**
|
|
|
* 淘口令解析&转链
|
|
|
* @param $kouling 淘口令
|
|
|
+ * @param $adzone_id 推广位
|
|
|
*/
|
|
|
- public static function taokoulingConvert($kouling)
|
|
|
+ public static function taokoulingConvert($kouling,$adzone_id)
|
|
|
{
|
|
|
- $app = self::getApp();
|
|
|
+ //根据pid找到淘宝信息
|
|
|
+ $taobao = TaobaoPidModel::query()
|
|
|
+ ->where("adzone_id",$adzone_id)
|
|
|
+ ->first();
|
|
|
+ $config = [
|
|
|
+ "appkey"=>$taobao["taobao_app_key"],//淘宝客appKey
|
|
|
+ "secretKey"=>$taobao["taobao_app_secret"],//secretKey
|
|
|
+ "format"=>"json",//返回的数据格式
|
|
|
+ "session"=>"",//授权接口(sc类的接口)需要带上
|
|
|
+ "sandbox"=>false,
|
|
|
+ ];
|
|
|
+ $app = Factory::tbk($config);
|
|
|
+
|
|
|
$params = [
|
|
|
"password_content"=>$kouling,
|
|
|
- "adzone_id"=>"70362850341"
|
|
|
+ "adzone_id"=>$adzone_id
|
|
|
];
|
|
|
$res = $app->tpwd->httpPost("taobao.tbk.tpwd.convert",$params);
|
|
|
$instance = new LoggerFactoryUtil(TaobaoLianMengUtil::class);
|
|
@@ -184,9 +222,21 @@ class TaobaoLianMengUtil extends BaseUtil
|
|
|
* @return mixed
|
|
|
* @throws TaobaoException
|
|
|
*/
|
|
|
- public static function getGoodsInfo($goodsId)
|
|
|
+ public static function getGoodsInfo($goodsId,$adzone_id)
|
|
|
{
|
|
|
- $app = self::getApp();
|
|
|
+ //根据pid找到淘宝信息
|
|
|
+ $taobao = TaobaoPidModel::query()
|
|
|
+ ->where("adzone_id",$adzone_id)
|
|
|
+ ->first();
|
|
|
+ $config = [
|
|
|
+ "appkey"=>$taobao["taobao_app_key"],//淘宝客appKey
|
|
|
+ "secretKey"=>$taobao["taobao_app_secret"],//secretKey
|
|
|
+ "format"=>"json",//返回的数据格式
|
|
|
+ "session"=>"",//授权接口(sc类的接口)需要带上
|
|
|
+ "sandbox"=>false,
|
|
|
+ ];
|
|
|
+ $app = Factory::tbk($config);
|
|
|
+
|
|
|
$params = [
|
|
|
"num_iids"=>$goodsId,
|
|
|
];
|