Crypt.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\extra\douyin;
  3. use yzh52521\EasyHttp\Http;
  4. class Crypt extends Base
  5. {
  6. public function getSessionKey(string $code = "")
  7. {
  8. $url = "https://developer.toutiao.com/api/apps/v2/jscode2session";
  9. $param = [
  10. "appid" => $this->config['appid'],
  11. "secret" => $this->config['secret'],
  12. "code" => $code
  13. ];
  14. $resp = Http::asJson()->post($url,$param)->array();
  15. if ($resp['err_no'] == 0) {
  16. return $resp['data'];
  17. }
  18. return [];
  19. }
  20. /**
  21. * 查询标签组信息 - 用于支付
  22. * @param int $goods_type
  23. */
  24. public function getTagGroupId(int $goods_type)
  25. {
  26. $url = $this->gateway."api/trade_basic/v1/developer/tag_query/";
  27. $param = [
  28. "goods_type" => $goods_type
  29. ];
  30. $resp = Http::asJson()->withHeaders($this->header)->post($url,$param)->array();
  31. if ($resp['err_no'] == 0) {
  32. return $resp['data'];
  33. }
  34. return [];
  35. }
  36. /**
  37. * 小程序获取手机号码
  38. * @param string $code
  39. * @return string
  40. */
  41. public function getMobile(string $code = ""):string
  42. {
  43. $url = $this->gateway."api/apps/v1/get_phonenumber_info/";
  44. $param = [
  45. "code" => $code
  46. ];
  47. $resp = Http::asJson()->withHeaders($this->header)->post($url,$param)->array();
  48. if ($resp['err_no'] == 0) {
  49. return $resp['data'];
  50. }
  51. return "";
  52. }
  53. }