私は知っているかもしれません.NET C#のためのfoursquare sdkです。 私は開発者のリファレンスに基づいていますが、私はトークンの要求中にそれを行うことができませんでした、私はエラーを取得し続けます。 私はVS 2008と開発中のサーバーを使用しています。私はこのエラーの前にURLの書き換えのために検索しますが、私はIISでホストされていませんし、web.configもチェックしています。助けてください、ありがとう。フォースクエアSDK for .NET
これは私のエラーです:パス「/ログイン」にアクセスするために使用さ
HTTP動詞POSTが許可されていません。
は、これは私の実装です:
HttpWebRequest request = null;
HttpWebResponse response = null;
StreamReader responseStream = null;
ASCIIEncoding ascii = null;
string key = ConfigurationManager.AppSettings["key"];
string secret = ConfigurationManager.AppSettings["secret"];
string callback = ConfigurationManager.AppSettings["callback"];
string obtainTokenUrl = ConfigurationManager.AppSettings["obtainTokenUrl"];
try
{
string postData = "client_id=" + key + "&response_type=code&redirect_uri=" + callback;
ascii = new ASCIIEncoding();
byte[] postBytes = ascii.GetBytes(postData);
try
{
request = WebRequest.Create(obtainTokenUrl) as HttpWebRequest;
}
catch (UriFormatException)
{
request = null;
}
if (request == null)
{
throw new ApplicationException("Invalid URL: " + obtainTokenUrl);
}
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
//add post data to request
Stream postStream = request.GetRequestStream();
postStream.Write(postBytes, 0, postBytes.Length);
postStream.Close();
response = (HttpWebResponse)request.GetResponse();
Encoding encode = Encoding.GetEncoding("utf-8");
responseStream = new StreamReader(response.GetResponseStream(), encode);
Response.Write(responseStream.ReadToEnd());
あなた自身がoauthをコーディングしていますか?あなたのためにこれを行う良いライブラリがあります。また、同様の古い質問があります。http://stackoverflow.com/questions/3611731/foursquare-oauth-authentication-net-sample – Rup