我已指定REDIRECT URI =" http://MyIP/MyApp/Instagram/MyPage.aspx"在Instagram管理客户端。
但我在这个页面上没有收到回复。 我想在MyPage.aspx的page_load()中编写一些逻辑
有人可以建议为什么重定向uri for instagram没有被点击,用户没有被重定向到这个页面?
感谢您的帮助。
Sanjeev Dutta
我的代码: protected void Page_Load(object sender,EventArgs e) { string ResponseStream = string.Empty; string Uri = string.Empty; string httpBody = string.Empty; string httpBody_SF = string.Empty; string Insta_Posts = string.Empty; string InstaUpdate = string.Empty; string OpStatus = string.Empty; InstagramSubscriptions New_Subscription = new InstagramSubscriptions(); InstagramStreamStore New_Stream = new InstagramStreamStore(); bool Is_Added = false;
try
{
if (Request.HttpMethod == "GET" && Request.Params["hub.mode"] == "subscribe")
{
Trace.Warn("Inside Hub Challenge Code : " + Request.Params["hub.challenge"].ToString());
Response.Write(Request.Params["hub.challenge"]);
}
else if (Request.HttpMethod == "POST")
{
Trace.Warn("Inside Instagram Streamer Code:Before Querying the API. HttpMethod:" + Request.HttpMethod);
using (StreamReader reader = new StreamReader(Request.InputStream))
{
ResponseStream = "{root:" + reader.ReadToEnd();
}
Trace.Warn("Inside Instagram Streamer Code:On response. ResponseStream:" + ResponseStream);
System.Xml.XmlDocument strXML = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(ResponseStream, "InstaUpdate");
Trace.Warn("Inside Instagram Streamer Code:Before reading GeoID XML String:" + strXML.InnerXml.ToString());
foreach (XmlNode X in strXML)
{
if (X.HasChildNodes)
{
foreach (XmlNode Y in X)
{
if (Y.Name == "root")
{
if (Y.HasChildNodes)
{
foreach (XmlNode Z in Y)
{
if (Z.Name == "object_id")
{
New_Subscription.SUBSCRIPTION_OBJECT_ID = Z.ChildNodes[0].Value;
}
if (Z.Name == "object")
{
New_Subscription.SUBSCRIPTION_OBJECT = Z.ChildNodes[0].Value;
}
if (Z.Name == "changed_aspect")
{
New_Subscription.ASPECT = Z.ChildNodes[0].Value;
}
if (Z.Name == "type")
{
New_Subscription.SUBSCRIPTION_TYPE = Z.ChildNodes[0].Value;
}
if (Z.Name == "subscription_id")
{
New_Subscription.SUBSCRIPTION_ID = int.Parse(Z.ChildNodes[0].Value);
}
if (Z.Name == "callback_url")
{
New_Subscription.CALLBACK_URL = Z.ChildNodes[0].Value;
}
if (Z.Name == "time")
{
double timestamp = double.Parse(Z.ChildNodes[0].Value);
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
DateTime Update_Date = origin.AddSeconds(timestamp).ToLocalTime();
New_Subscription.POST_UPDATE_TIME = Update_Date;
}
}
}
}
}
}
}
Trace.Warn("O HELLO ","Inside Instagram Streamer Code. Before Adding Streams For Geo ID:" + New_Subscription.SUBSCRIPTION_OBJECT_ID);
Is_Added = New_Stream.AddLiveStreams(New_Subscription);
if (Is_Added == true)
OpStatus = "true";
else
OpStatus = "false";
// Trace.Write("After AddLiveStreams : " + OpStatus);
}
}
catch (SqlException SQLEx)
{
Trace.Write("Inside SqlException: " + SQLEx.Message);
}
catch (WebException WEx)
{
Trace.Write("Inside WebException: " + WEx.Message);
}
catch (Exception ex)
{
Trace.Write("Inside Application Exception: " + ex.Message);
}
}