次のコードを使用して、get リクエストを facebook グラフ api oauth サーバーに送信しています。
public string GetAccessToken(string code)
{
HttpWebRequest req = (HttpWebRequest) WebRequest.Create(@"https://graph.facebook.com/oauth/access_token?client_id=249725835046216&redirect_uri=http://localhost:2794/&client_secret=APP_SECRETa&code=" + code);
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
string response=res.GetResponseStream().ToString();
return response;
}
上記のコードは、次の例外をスローします。
The remote server returned an error: (400) Bad Request.
一方、ブラウザに同じ URL を入力すると、機能します。助けてください、どこが間違っていますか?
(PS URL の APP_SECRET は必ずシークレット キーに置き換えています)