Mini.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace fast;
  3. use EasyWeChat\Factory;
  4. /**
  5. * 版本检测和对比
  6. */
  7. class Mini
  8. {
  9. public static function mini($client){
  10. static $app=[];
  11. if(!isset($app[$client])) {
  12. if($client==1) {
  13. $config = [
  14. 'app_id' => config('site.user_appid'),
  15. 'secret' => config('site.user_appsecret'),
  16. // 下面为可选项
  17. // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
  18. 'response_type' => 'array',
  19. 'log' => [
  20. 'level' => 'debug',
  21. 'file' => RUNTIME_PATH . '/wechat_user.log',
  22. ],
  23. ];
  24. }else{
  25. $config = [
  26. 'app_id' => config('site.sender_appid'),
  27. 'secret' => config('site.sender_appserret'),
  28. // 下面为可选项
  29. // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
  30. 'response_type' => 'array',
  31. 'log' => [
  32. 'level' => 'debug',
  33. 'file' => RUNTIME_PATH . '/wechat_sender.log',
  34. ],
  35. ];
  36. }
  37. $app[$client]=Factory::miniProgram($config);
  38. }
  39. return $app[$client];
  40. }
  41. public static function payment($client='user'){
  42. static $app=[];
  43. if(!isset($app[$client])) {
  44. $config = [
  45. 'app_id' => config('site.user_appid'),
  46. 'secret' => config('site.user_appsecret'),
  47. // 下面为可选项
  48. // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
  49. 'response_type' => 'array',
  50. 'log' => [
  51. 'level' => 'debug',
  52. 'file' => RUNTIME_PATH . '/wechat_user.log',
  53. ],
  54. ];
  55. $app[$client]=Factory::payment($config);
  56. }
  57. return $app[$client];
  58. }
  59. }