wechatpay-apiv3 / wechatpay-php

微信支付 APIv3 的官方 PHP Library,同时也支持 APIv2
Apache License 2.0
496 stars 100 forks source link

设置代理转发 #125

Closed wsqun closed 1 year ago

wsqun commented 1 year ago

运行环境

- OS:Linux
- PHP:PHP7
- wechatpay-php:^1.4

描述你的问题现象

微信后台限制了IP白名单配置数量 要如何设置proxy 比如Guzzle可以设置proxy

TheNorthMemory commented 1 year ago

see https://docs.guzzlephp.org/en/stable/request-options.html#proxy

proxy

Summary

Pass a string to specify an HTTP proxy, or an array to specify different proxies for different protocols.

examples:

全局设置

$instance = Builder::factory([
    // 其他必填参数
    // 新增代理设置
    'proxy' => [
        'http'  => 'http://localhost:8125', // Use this proxy with "http"
        'https' => 'http://localhost:9124', // Use this proxy with "https",
        'no' => ['.mit.edu', 'foo.com']    // Don't use a proxy with these
    ],
]);

每请求设置

$resp = $instance->v3->certificates->get([
    // 新增代理设置
    'proxy' => [
        'http'  => 'http://localhost:8125', // Use this proxy with "http"
        'https' => 'http://localhost:9124', // Use this proxy with "https",
        'no' => ['.mit.edu', 'foo.com']    // Don't use a proxy with these
    ],
]);
wsqun commented 1 year ago

感谢 可以了