ByteDanceCode2Session.php 578 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace app\service\byte_dance;
  3. use think\Cache;
  4. class ByteDanceCode2Session implements ByteDanceInterface {
  5. protected $code;
  6. public function setCode($code)
  7. {
  8. $this->code = $code;
  9. return $this;
  10. }
  11. public function get()
  12. {
  13. return ByteDance::httpPost('https://developer.toutiao.com/api/apps/v2/jscode2session',$this->params());
  14. }
  15. protected function params(){
  16. return [
  17. 'appid'=>ByteDance::appId(),
  18. 'secret'=>ByteDance::appSecret(),
  19. 'code'=>$this->code,
  20. ];
  21. }
  22. }