I am using Asp.net to subscribe to facebook realtime API.I have created a Httphandler to handle http GET/POST request.
public class SubCallback : IHttpHandler {
// This is secret verify_token that you should pass
// to Facebook when add/modify a subscription.
// Make sure to replace it with your own string!!
public const string VERIFY_TOKEN = "abc";
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
HttpRequest request = context.Request;
if (request.HttpMethod == "GET" &&
request.Params["hub.mode"] == "subscribe" &&
request.Params["hub.verify_token"] == VERIFY_TOKEN)
{
context.Response.ContentType = "text/plain";
context.Response.Write(request.Params["hub.challenge"]);
}
else if (request.HttpMethod == "POST")
{
StreamReader reader = new StreamReader(request.InputStream);
string jsonString = reader.ReadToEnd();
// Now use your favorate JSON decode and have fun with the data
}
}
public bool IsReusable {
get {
return false;
}
}
I am able to subscribe to realtime API .But when i try to get the information i am getting null in content
const string VERIFY_TOKEN = "abc";
string callbackurl = "http://somepublicurl/Default.aspx";
string q = "?hub.mode=subscribe&&hub.verify_token=abc";
var newt = callbackurl + q;
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(newt);
HttpWebResponse response = (HttpWebResponse)
request.GetResponse();
Stream resStream = response.GetResponseStream();
I am always getting resStream.Length null because request.Parms["hub.challenge"] is always null ?
Any thoughts ?
Aucun commentaire:
Enregistrer un commentaire