Starting from Senparc.Weixin.dll v4.5.7, we provide a Web proxy function to facilitate applications in restricted LANs to call interfaces smoothly.
The relevant modifications are in Senparc.Weixin/Utilities/HttpUtility/RequestUtility.cs:
#region 代理 private static WebProxy _webproxy = null; /// <summary> /// 设置Web代理 /// </summary> /// <param name="host"></param> /// <param name="port"></param> /// <param name="username"></param> /// <param name="password"></param> public static void SetHttpProxy(string host, string port, string username, string password) { ICredentials cred; cred = new NetworkCredential(username, password); if (!string.IsNullOrEmpty(host)) { _webproxy = new WebProxy(host + ":" + port ?? "80", true, null, cred); } } /// <summary> /// 清除Web代理状态 /// </summary> public static void RemoveHttpProxy() { _webproxy = null; } #endregion
The usage method is as follows:
1. Set the proxy message before calling the interface (Only needed once globally):
//设置 RequestUtility.SetHttpProxy("http://192.168.1.130","8088","username","pwd");
2. When the interface method is called normally, this proxy parameter will be automatically applied.
When the proxy status needs to be cleared, the RemoveHttpProxy() method is executed globally:
//清除 RequestUtility.RemoveHttpProxy();
For more articles related to WeChat public platform development: Web proxy function, please pay attention PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool