나는 .NET C#을위한 foursquare sdk가 있는지 알고 있습니다. 개발자 참조를 기반으로하고 있지만 토큰을 요청하는 도중에 오류가 발생했습니다. 오류가 계속 발생합니다. VS 2008 및 개발중인 서버를 사용하고 있습니다. URL 재 작성 때문에이 오류가 발생하기 전에 검색하지만 IIS에서 호스트되지 않았으며 web.config도 확인했습니다. 도와주세요, 고마워요.에 대한 Foursquare SDK
이 내 오류입니다 : '/ 로그인'경로에 액세스하는 데 사용
는 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