MediaOAuthController.php 988 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\v1\controller\advert;
  3. use app\v1\logic\advert\MediaListLogic;
  4. use app\v1\validate\advert\MediaListValidate;
  5. use plugin\saiadmin\basic\BaseController;
  6. use support\Request;
  7. use support\Response;
  8. /**
  9. * 媒体开发者账号-应用授权回调地址
  10. */
  11. class MediaOAuthController extends BaseController
  12. {
  13. /**
  14. * 构造函数
  15. */
  16. public function __construct()
  17. {
  18. $this->logic = new MediaListLogic();
  19. parent::__construct();
  20. }
  21. /**
  22. * https://api.com/MediaOAuth/callback/{channel}
  23. */
  24. public function callback(Request $request, string $channel): Response
  25. {
  26. $callback = $request->get();
  27. $channel = ucfirst($channel); // 如 "toutiao" → "Toutiao""
  28. $channelClass = "app\\adapter\\{$channel}Adapter"; // 适配器类名
  29. $oathInfo = (new $channelClass)->OAuth($callback);
  30. // 写授权结果
  31. // 获取广告账户列表
  32. return $this->success();
  33. }
  34. }