Client.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. /*
  8. * This file is part of the OtkurBiz/ByteDance.
  9. *
  10. * (c) alim <alim@bulutbazar.com>
  11. *
  12. * This source file is subject to the MIT license that is bundled
  13. * with this source code in the file LICENSE.
  14. */
  15. namespace ByteDance\MiniProgram\KVData;
  16. use ByteDance\Kernel\BaseClient;
  17. /**
  18. * Class Client.
  19. *
  20. * @author alim <alim@bulutbazar.com>
  21. */
  22. class Client extends BaseClient
  23. {
  24. /**
  25. * Set User Storage
  26. * 当 key 是开发者所配置的排行榜 key 时,value 的内容应该满足KVData所指出的形式, 即形如 "{\"ttgame\":{\"score\":1}}".
  27. *
  28. * openid 登录用户唯一标识
  29. * signature 用户登录态签名,参考用户登录态签名算法
  30. * sig_method 用户登录态签名的编码方法,参考用户登录态签名算法
  31. * kv_list (body 中) 要设置的用户数据
  32. *
  33. * @throws \ByteDance\Kernel\Exceptions\InvalidConfigException
  34. *
  35. * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
  36. */
  37. public function set(string $openid, string $signature, string $sig_method, string $kv_list)
  38. {
  39. return $this->httpPost('api/apps/set_user_storage', ['openid'=>$openid, 'signature' => $signature, 'sig_method'=>$sig_method, 'kv_list'=>$kv_list]);
  40. }
  41. /**
  42. * Set User Storage
  43. * 当 key 是开发者所配置的排行榜 key 时,value 的内容应该满足KVData所指出的形式, 即形如 "{\"ttgame\":{\"score\":1}}".
  44. *
  45. * openid 登录用户唯一标识
  46. * signature 用户登录态签名,参考用户登录态签名算法
  47. * sig_method 用户登录态签名的编码方法,参考用户登录态签名算法
  48. * key (body 中) 要删除的用户数据的 key list
  49. *
  50. * @throws \ByteDance\Kernel\Exceptions\InvalidConfigException
  51. *
  52. * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
  53. */
  54. public function remove(string $openid, string $signature, string $sig_method, string $key)
  55. {
  56. return $this->httpPost('api/apps/remove_user_storage', ['openid'=>$openid, 'signature' => $signature, 'sig_method'=>$sig_method, 'key'=>$key]);
  57. }
  58. }