こんにちはすべて私はHttpWebRequestメソッドを使用してFacebookにオープングラフアクションを投稿しようとしています。
これが私のリクエスト方法です
public static string RequestUrl(string action, String HTTPMETHOD, dynamic postdata = null)
{
string results = "";
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(action);
if (HTTPMETHOD == "GET")
{
req.Method = WebRequestMethods.Http.Get;
}
else if (HTTPMETHOD == "POST")
{
ASCIIEncoding encoding = new ASCIIEncoding();
req.Method = WebRequestMethods.Http.Post;
byte[] data = encoding.GetBytes(postdata.sneaqer);
req.ContentLength = data.Length;
req.ContentType = "application/x-www-form-urlencoded";
Stream newStream = req.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
}
else if (HTTPMETHOD == "DELETE")
{
req.Method = "DELETE";
ASCIIEncoding encoding = new ASCIIEncoding();
}
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());
results = sr.ReadToEnd();
sr.Close();
}
catch (Exception ex)
{
Error.Log("ERROR: Common.cs requestUrl() " + ex.Message + " " + action);
}
return results;
}
これは私がこれまでに試したことです
var url = "https://graph.facebook.com/" + personFacebookUserId + "/verbNamespace:follow";
dynamic parameters = new System.Dynamic.ExpandoObject();
parameters.person = "http:" + Configuration.getConfigValue("SiteUrl") + "OG/OpenGraphAction.aspx?type=follow&facebookProfilePicture=" + friendFacebookUserId;
string result = Common.RequestUrl(url, "POST", parameters);
エラーサーバーが不正なリクエストを返しました。問題は、パラメーターを渡す方法にあると思います。人が対象であり、従うことが行動です。
助けてくれてありがとう。