我有一個網址"http://mt0.google.com/vt/[email protected]&hl=en&x=11728&y=7595&z=14&s=Galileo"
用於從Internet獲取Google Tiles。如果我從瀏覽器(任何)使用此Google Tile網址,我會成功獲取Google Tiles(地圖)。但問題是,如果我試圖訪問這個URL programmaticaly,我得到一個錯誤:HTTP 403禁止錯誤。HTTP 403:通過C#程序訪問Google Tile時出現禁止錯誤
可能是什麼問題?我需要在我的程序中進行某種設置嗎?
我的代碼訪問URL如下:
byte[] imageBuffer = null;
try
{
WebClient client = new WebClient();
// It's a sample URL to get Tile from Google as on 29-06-2010
string url = "http://mt0.google.com/vt/[email protected]&hl=en&x=11728&y=7595&z=14&s=Galileo";
imageBuffer = client.DownloadData(new Uri(url));
}
catch (WebException we)
{
Debug.Print(we.Message);
return null;
}
return imageBuffer;
在這裏,在catch塊,我得到HTTP 403的異常:禁止錯誤
是的,它的工作..感謝您的詳細解釋。 我是否需要添加更適合的「用戶代理」,如使用的操作系統或安裝在機器或其他類型的瀏覽器? – 2010-07-09 04:39:14