【已解决】请问公共号消息发送接口推送的轻应用链接怎...
金蝶云社区-132xxxx2050
132xxxx2050
1人赞赏了该文章 1,339次浏览 未经作者许可,禁止转载编辑于2017年03月07日 11:33:45

现在我们想要通过公共号里推送的轻应用链接消息打开我们的轻应用 但是通过不了云之家的登录验证 请问该怎么解决云之家的登录验证这个问题
目前我们用的是云之家服务端的公共号消息发送接口
里面有参数提及到了打开轻应用的方式 但是不是特别理解
如下:
[quote]"appid": 如果打开的链接是轻应用,必须传入轻应用号讯通才能传入参数ticket,参考<轻应用框架>开发,[/quote]

代码如下:
[code]
public override void OnLoad(EventArgs e)
{
base.OnLoad(e);
//消息推送
string url = "https://do.yunzhijia.com/pubacc/pubsend";
string eid = "10182xxx";
string pub = "XT-45d46470-281c-xxxxxxxx5-8ea1735df9e6";
string time = ((DateTime.Now.Ticks - Convert.ToDateTime("1970-01-01 08:00:00").Ticks) / 10000).ToString();
string nonce = "123456789";
string key = "9d94117xxxxxxxxxx2f32d024b34";
string[] array = new string[] { eid, pub, key, nonce, time };
string sha1 = sha(array);
string text = "轻应用链接";

string test = "http://192.168.1.150/K3Cloud/mobile/k3cloud.html?entryrole=XT&appid=101091440&formId=SY_NB_PCBBJSJGCLB&formType=mobilelist";
string json = "{\"from\":{\"no\":\"" + eid + "\",\"pub\":\"" + pub + "\",\"time\":\"" + time + "\",\"nonce\":\"" + nonce + "\",\"pubtoken\":\"" + sha1 + "\"},\"to\":[{\"no\":\"" + eid + "\",\"user\":[\"589aaa86xxxxxxx835a1f\"],\"code\":\"0\"}],\"type\":\"5\",\"msg\":{\"text\":\"" + text + "\",\"url\":\"" + test + "\",\"appid\":\"10182xxx\",\"todo\":\"0\"}}";
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/json; charset=utf-8";
request.ContentLength = Encoding.UTF8.GetBytes(json).Length;
Stream writer = request.GetRequestStream();
writer.Write(Encoding.UTF8.GetBytes(json), 0, Encoding.UTF8.GetBytes(json).Length);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string encoding = response.ContentEncoding;
if (encoding == null || encoding.Length < 1)
{
encoding = "UTF-8";
}
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding(encoding));
string ret = reader.ReadToEnd();
}
catch (Exception ex)
{
throw ex;
}
}

public static string sha(string[] data)
{
Array.Sort(data, StringComparer.Ordinal);
string sortdata = String.Join("", data);
string pubtoken = FormsAuthentication.HashPasswordForStoringInConfigFile(sortdata, "SHA1");
return pubtoken;
}[/code]

1.jpg(55.48KB)

2.jpg(38.36KB)