简体   繁体   中英

System.Net.WebException: The remote server returned an error: (403) Forbidden when access Google API

I'm using the Google API on my website. It works fine from my localhost, but on the live server I get the following error:

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

I'm using the code found here: http://www.thecyberwizard.com/index.php/5/google-analytics-api-in-c-part-1/

And from debugging, I see that the error occurs on the

HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();

command.

Does anyone know what could be causing the error (again, the error happens only on the server. When I run this code locally on my computer, it runs fine and retrieves a short url).

I have to turn off billing still I get the following error:

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

How can I resolve this?

它的工作原理是将_autoPostData值更改为"â?accountType=HOSTED_OR_GOOGLE&Email={0}&Passwd={1}&service=analytics&source=thecyberwizard.comâ"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM