Crypt.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. print_r($resp);
  16. if ($resp['err_no'] == 0) {
  17. return $resp['data'];
  18. }
  19. return [];
  20. }
  21. /**
  22. * 查询标签组信息 - 用于支付
  23. * @param int $goods_type
  24. */
  25. public function getTagGroupId(int $goods_type)
  26. {
  27. $url = $this->gateway."api/trade_basic/v1/developer/tag_query/";
  28. $param = [
  29. "goods_type" => $goods_type
  30. ];
  31. $resp = Http::asJson()->withHeaders($this->header)->post($url,$param)->array();
  32. if ($resp['err_no'] == 0) {
  33. return $resp['data'];
  34. }
  35. return [];
  36. }
  37. /**
  38. * 小程序获取手机号码
  39. * @param string $code
  40. * @return string
  41. */
  42. public function getMobile(string $code = ""):string
  43. {
  44. $url = $this->gateway."api/apps/v1/get_phonenumber_info/";
  45. $param = [
  46. "code" => $code
  47. ];
  48. $resp = Http::asJson()->withHeaders($this->header)->post($url,$param)->array();
  49. if ($resp['err_no'] == 0) {
  50. return $resp['data'];
  51. }
  52. return "";
  53. }
  54. }