gpt4 book ai didi

c# - 适用于 .net 的 Foursquare SDK

转载 作者:行者123 更新时间:2023-11-30 19:49:07 27 4
gpt4 key购买 nike

我可以知道是否有用于 .NET C# 的 foursquare sdk。我正在根据开发人员引用进行操作,但我在请求 token 期间未能做到,我不断收到错误消息。我正在使用 VS 2008 和开发服务器。由于 url 重写,我在此错误之前进行了搜索,但我没有托管在 IIS 中,而且我也检查了 web.config,但也不走运。请帮忙,谢谢。

这是我的错误:

不允许使用 HTTP 动词 POST 访问路径“/login”。

这是我的实现:

        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());

最佳答案

好吧,这可能是一种迂回的回答。但也许您可以查看适用于 Windows Phone 7 的开源 4square 应用程序:
http://4square.codeplex.com/

由于您可以查看源代码,因此您可以了解它们是如何与 4sq API 交互的:-)

关于c# - 适用于 .net 的 Foursquare SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4460012/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com