可能我知道有没有四方的SDK的.NET C#。 我的基础上做开发的参考,但我失败时请求令牌做到这一点,我一直得到错误。 我使用VS 2008和正在开发服务器。我这个错误,因为URL重写之前搜索,但我不会在IIS托管和我也有检查web.config中,没有运气也。请大家帮帮忙,谢谢。
这是我的错误:
使用的HTTP动词POST访问路径/ login'是不允许的。
这是我的实现:
HttpWebRequest的要求= NULL;
HttpWebResponse响应=无效;
StreamReader的responseStream = NULL;
ASCIIEncoding ASCII = NULL;
字符串键= ConfigurationManager.AppSettings [钥匙]。
串秘密= ConfigurationManager.AppSettings [秘密];
字符串回调= ConfigurationManager.AppSettings [回调];
字符串obtainTokenUrl = ConfigurationManager.AppSettings [obtainTokenUrl];
尝试
{
字符串POSTDATA =CLIENT_ID =+键+&放大器; RESPONSE_TYPE = code和; redirect_uri =+回调;
ASCII =新ASCIIEncoding();
byte []的postBytes = ascii.GetBytes(POSTDATA);
尝试
{
要求= WebRequest.Create(obtainTokenUrl)为HttpWebRequest的;
}
赶上(UriFormatException)
{
请求= NULL;
}
如果(要求== NULL)
{
抛出新ApplicationException的(无效的URL:+ obtainTokenUrl);
}
request.Method =POST;
request.ContentType =应用/的X WWW的形式urlen codeD;
request.ContentLength = postBytes.Length;
//后的数据添加到请求
流postStream = request.GetRequestStream();
postStream.Write(postBytes,0,postBytes.Length);
postStream.Close();
响应=(HttpWebResponse)request.GetResponse();
编码连接code = Encoding.GetEncoding(UTF-8);
responseStream =新的StreamReader(response.GetResponseStream(),EN code);
回复于(responseStream.ReadToEnd());
解决方案
SharpSquare - FourSquare的SDK的.NET HTTP: //www.igloolab.com/sharpsquare/
may i know is there any foursquare sdk for .NET C#. I am doing based on the developer reference but i failed to do it during request for token, i keep on getting the error. I am using VS 2008 and under development server. I search before this error because of url rewriting, but i'm not hosted in IIS and i also have check the web.config, no luck also. Please help, thanks.
This is my error:
The HTTP verb POST used to access path '/login' is not allowed.
This is my implementation:
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());
解决方案
SharpSquare - FourSquare SDK for .NET http://www.igloolab.com/sharpsquare/
相关推荐
最新文章