The remote server returned an error: (403) Forbidden.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Net.WebException: The remote server returned an error: (403) Forbidden.
Source Error:
|
Source File: c:\Inetpub\wwwroot\twitweb\App_Code\oAuthTwitter.cs Line: 273
Stack Trace:
|
if you are using .net sample code getting this error while trying to do status update use following code in default.aspx:
using
System;using
System.Data;using
System.Configuration;using
System.Collections;using
System.Web;using
System.Web.Security;using
System.Web.UI;using
System.Web.UI.WebControls;using
System.Web.UI.WebControls.WebParts;using
System.Web.UI.HtmlControls;using
oAuthExample;public
partial class _Default : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
string url = ""; string xml = ""; oAuthTwitter oAuth = new oAuthTwitter(); if (Request["oauth_token"] == null){
//Redirect the user to Twitter for authorization. //Using oauth_callback for local testing.oAuth.CallBackUrl =
"http://localhost/twitweb/default6.aspx";Response.Redirect(oAuth.AuthorizationLinkGet());
}
else{
//Get the access token and secret.oAuth.AccessTokenGet(Request[
"oauth_token"], Request["oauth_verifier"]); if (oAuth.TokenSecret.Length > 0){
//We now have the credentials, so make a call to the Twitter API. // url = "http://twitter.com/account/verify_credentials.xml"; //xml = oAuth.oAuthWebRequest(oAuthTwitter.Method.GET, url, String.Empty); //apiResponse.InnerHtml = Server.HtmlEncode(xml); //POST Testurl =
"http://twitter.com/statuses/update.xml";xml = oAuth.oAuthWebRequest(
oAuthTwitter.Method.POST, url, "status=" + oAuth.UrlEncode("test 123 Hello Testing the .NET oAuth API 3"));apiResponse.InnerHtml = Server.HtmlEncode(xml);
}
}
}
}
No comments:
Post a Comment