Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the Web Agent function in the Development of Wechat Public platform

Shulou Source: shulou.com Published: 2022-06-03 16:13:29 10月03日 Update

This article mainly introduces the Wechat public platform development of how to achieve Web proxy function, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Since the Senparc.Weixin.dll v4.5.7 release, we have provided the Web proxy function so that applications in restricted Lans can call the interface smoothly.

All the relevant changes are in Senparc.Weixin/Utilities/HttpUtility/RequestUtility.cs:

# region agent private static WebProxy _ webproxy = null; / set Web agent / 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);}} / clear Web agent status / public static void RemoveHttpProxy () {_ webproxy = null } # endregion

The method of use is as follows:

1. Set the proxy message before calling the API (global only once):

/ / set RequestUtility.SetHttpProxy ("http://192.168.1.130","8088","username","pwd");"

2. Call the interface method normally, and this proxy parameter will be applied automatically.

When you need to clear the agent state, execute the RemoveHttpProxy () method globally:

/ clear RequestUtility.RemoveHttpProxy (); Thank you for reading this article carefully. I hope the article "how to achieve Web proxy function in the development of Wechat public platform" shared by the editor will be helpful to you. At the same time, I hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Tags: Agents articles functions interfaces methods public platform development global status application value usage interests parameters just at the same time local area local area network more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Technology OPPO Reno vpn Apple