目前看不出来这个接口有哪些具体运用,但是既然有这个接口,那我们就试试能不能用

 

修改WeCharBase.cs,新增以下2个方法

  1. 1 public static string ServerIPs
  2. 2 {
  3. 3 get { return GetServerIPs(); }
  4. 4 }
  5. 5
  6. 6 /// <summary>获取所有服务器IP</summary>
  7. 7 /// <returns></returns>
  8. 8 private static string GetServerIPs()
  9. 9 {
  10. 10 try
  11. 11 {
  12. 12 var client = new WebClient();
  13. 13 client.Encoding = Encoding.UTF8;
  14. 14 return client.DownloadString(string.Format("https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token={0}", WeCharBase.AccessToken));
  15. 15 }
  16. 16 catch (Exception ex)
  17. 17 {
  18. 18 return ex.Message;
  19. 19 }
  20. 20 }

 

修改控制器:SubscriptController.cs

  1. 1 /// <summary>获取微信服务器IP地址</summary>
  2. 2 /// <returns></returns>
  3. 3 public ActionResult ViewServerIPs()
  4. 4 {
  5. 5 return View();
  6. 6 }
  7. 7
  8. 8 /// <summary>获取微信服务器IP地址</summary>
  9. 9 /// <returns></returns>
  10. 10 public ActionResult GetServerIPs()
  11. 11 {
  12. 12 return Content(WeCharBase.ServerIPs);
  13. 13 }

新增视图

  1. 1 <script type="text/javascript" language="javascript">
  2. 2 $(document).ready(function () {
  3. 3 $("#btnGetServerIPs").click(function () {
  4. 4 $.ajax({
  5. 5 type: "Get",
  6. 6 url: "/Subscript/GetServerIPs",
  7. 7 success: function (responseTest) {
  8. 8 $("#txtServerIPs").text(responseTest);
  9. 9 }
  10. 10 });
  11. 11 });
  12. 12 });
  13. 13 </script>
  14. 14
  15. 15 <table>
  16. 16 <tr>
  17. 17 <td>
  18. 18 <div class="title">获取微信服务器IP地址</div>
  19. 19 <textarea id="txtServerIPs" name="txtServerIPs" rows="10" style="width:500px"></textarea>
  20. 20 </td>
  21. 21 <td><input class="btncss" id="btnGetServerIPs" type="button" value=" 获取 " /></td>
  22. 22 </tr>
  23. 23 </table>

 

成功了,虽然不知道有什么用处,呵呵

 

  1. 微信公众号平台接口开发:成为开发者 
  2. 微信公众号平台接口开发:基础支持,获取access_token
  3. 微信公众号平台接口开发:基础支持,获取微信服务器IP地址
  4. 微信公众号平台接口开发:发送客服消息
  5. 微信公众号平台接口开发:菜单管理
  6. 微信公众号平台接口开发:待续

 

版权声明:本文为lanxiaoke原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/lanxiaoke/p/6413114.html