Ver código fonte

基础文件

PC-202304251453\Administrator 3 meses atrás
pai
commit
6d8354f044

+ 45 - 0
app/adapter/GdtAdapter.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace app\adapter;
+
+// 广点通-适配器
+use GuzzleHttp\Client;
+
+class GdtAdapter
+{
+    public function OAuth($info)
+    {
+        // 执行验证callback, 返回授权后的字段,跟数据库对应
+        return [
+            "advertiser_id" => "",
+            "advertiser_name" => "",
+            "access_token" => "",
+            "refresh_token" => "",
+            "expire_time" => "",
+        ];
+    }
+
+    // 获取子账号列表
+    public function getSubAccounts($pmid)
+    {
+
+    }
+
+    // 刷新 token
+    public function refreshToken($pmid)
+    {
+
+    }
+
+    // 获取小时消耗
+    public function getHourlyCost($advertiserId, $accessToken, $date): array
+    {
+        return [];
+    }
+
+    // 获取媒体消耗
+    public function getVideoCost($advertiserId, $accessToken, $date): array
+    {
+        return [];
+    }
+}

+ 11 - 0
app/adapter/ToutiaoAdapter.php

@@ -7,6 +7,17 @@ use GuzzleHttp\Client;
 
 class ToutiaoAdapter
 {
+    public function OAuth($info)
+    {
+        // 执行验证callback, 返回授权后的字段,跟数据库对应
+        return [
+            "advertiser_id" => "",
+            "advertiser_name" => "",
+            "access_token" => "",
+            "refresh_token" => "",
+            "expire_time" => "",
+        ];
+    }
     // 获取子账号列表
     public function getSubAccounts($pmid)
     {

+ 44 - 0
app/v1/controller/advert/MediaOAuthController.php

@@ -0,0 +1,44 @@
+<?php
+
+namespace app\v1\controller\advert;
+
+use app\v1\logic\advert\MediaListLogic;
+use app\v1\validate\advert\MediaListValidate;
+use plugin\saiadmin\basic\BaseController;
+use support\Request;
+use support\Response;
+
+/**
+ * 广告媒体表控制器
+ */
+class MediaOAuthController extends BaseController
+{
+    /**
+     * 构造函数
+     */
+    public function __construct()
+    {
+        $this->logic = new MediaListLogic();
+        parent::__construct();
+    }
+
+    /**
+     * https://api.com/MediaOAuth/callback/{channel}
+     */
+    public function callback(Request $request, string $channel): Response
+    {
+        $callback = $request->get();
+
+        $channel = ucfirst($channel); // 如 "toutiao" → "Toutiao""
+        $channelClass = "app\\adapter\\{$channel}Adapter"; // 适配器类名
+
+        $oathInfo = (new $channelClass)->OAuth($callback);
+
+        // 写授权结果
+
+        // 获取广告账户列表
+
+        return $this->success();
+    }
+
+}