如果在Http連線時,出現<html><head><title>Request Rejected</title></head><body>The requested URL was rejected. Please consult with your administrator.<br><br>Your support ID is: 10354558644722555446</body></html>訊息,表示你沒設定RequestProperty。
解決方法:
URL u = new URL(url);
HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setRequestProperty("User-Agent", "Mozilla/5.0"); //要加入這行程式碼
c.connect();
沒有留言:
張貼留言