系统.Net.WebException:访问Google API时,远程服务器返回错误:(403)禁止

4

我在我的网站上使用Google API。它在我的本地主机上运行良好,但在实际服务器上出现以下错误:

System.Net.WebException: The remote server returned an error: (403)
Forbidden.
at System.Net.HttpWebRequest.GetResponse()
at GoogleUrlShortnerApi.Shorten(String url)

我正在使用这里找到的代码:http://www.thecyberwizard.com/index.php/5/google-analytics-api-in-c-part-1/ 从调试中,我看到错误发生在
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();

命令。

有人知道是什么原因导致错误(需要注意的是,这个错误只在服务器上出现。当我在本地电脑上运行此代码时,它可以正常运行并检索到一个短网址)。

我必须关闭计费,否则我会得到以下错误:

System.Net.WebException: The remote server returned an error: (403)  

我该如何解决这个问题?
1个回答

0

通过将 _autoPostData 的值更改为 "â?accountType=HOSTED_OR_GOOGLE&Email={0}&Passwd={1}&service=analytics&source=thecyberwizard.comâ",它可以正常工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接