如何使用回调网址 [英] How to use callback url

查看:169
本文介绍了如何使用回调网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有个问题 .我正在使用Workwave API 问题,但我不知道如何解决此问题,这是
1>如何创建回调网址?
2>如何从Workwave那里获取数据?

请帮助我.感谢您的宝贵答复.

我尝试过的事情:

为了得到我试试这个


Hi all,
i have a problem . I am working with workwave API problem that i am not understanding how can i resolve this is
1> how can i create a callback url ?
2> How can i get data from workwave to there ?

please help me about this. thanks for your valuable answer.

What I have tried:

for get i try this


private string CreateToken(string message, string secret)
       {
           secret = secret ?? "";
           var encoding = new System.Text.ASCIIEncoding();
           byte[] keyByte = encoding.GetBytes(secret);
           byte[] messageBytes = encoding.GetBytes(message);
           using (var hmacsha256 = new HMACSHA256(keyByte))
           {
               byte[] hashmessage = hmacsha256.ComputeHash(messageBytes);
               return Convert.ToBase64String(hashmessage);
           }
       }


string dataUrl = "{\"url \": \"http://185.74.157.252:8096/json.aspx \",\"signaturePassword\" : \""+ signPassword + "\",\"test\":\"true\"}";


string Str = CallBackUrl("https://wwrm.workwave.com/api/v1/callback", dataUrl, userid, ApiKey);





string signPassword = CreateToken("http://185.74.157.252:8096/json.aspx" + " w/", ApiKey);


string CallBackUrl(string url, string urlregister, string bigApiUserID, string BigApiKey)
       {
           string responseStr = "";
           HttpStatusCode statusCode;
           WebRequest request = WebRequest.Create(url);
           request.Credentials = new NetworkCredential(bigApiUserID, BigApiKey);
           request.Method = "POST";
           byte[] bytes;
           bytes = System.Text.Encoding.ASCII.GetBytes(urlregister);
           request.Headers.Add("X-WorkWave-Key", BigApiKey);
           request.ContentType = "application/json";
           request.ContentLength = bytes.Length;
           Stream requestStream = request.GetRequestStream();
           requestStream.Write(bytes, 0, bytes.Length);
           requestStream.Close();
           HttpWebResponse response;
           try
           {
               response = (HttpWebResponse)request.GetResponse();
               statusCode = response.StatusCode;
               if (Convert.ToString(response.StatusCode) == "OK")
               {
                   Stream responseStream = response.GetResponseStream();
                   responseStr = new StreamReader(responseStream).ReadToEnd();
                   return responseStr;
               }
           }
           catch (WebException  ex)
           {
               using (var stream = ex.Response.GetResponseStream())
               using (var reader = new StreamReader(stream))
               {
                   string str = Convert.ToString(reader.ReadToEnd());
               }

           }


           return responseStr;
       }

推荐答案

看看workwave API文档,看起来还不错.
1.启动并运行面向公众的Web服务器(强烈建议使用https)
2.创建您的Web服务,看起来他们需要一个RESTful api回调URL.我个人将c#WebAPI项目用于此类工作.它需要接受JSON数据的POST操作.
我将创建模仿其json布局的类,以便您可以从它们中很好地反序列化该类型的对象.
3.完成所有Restful API服务的设置后,您需要更新Workwave的系统.上面的代码可能有用,但是您需要使用POST操作而不是GET操作来使用新的Web服务URL更新其系统.这样,他们就会通过呼叫您提供给他们的URL与您联系.

那是一个非常高级的视图,但它的确不错.
Looking at the workwave API documentation this doesn''t look too bad.
1. Get your public facing webserver up and running (https would be highly recommended)
2. Create your webservice, looks like they need a RESTful api call back url. I personally use c# WebAPI projects for stuff like this. It needs to accept POST actions of JSON data.
I would create classes that mimic their json layout so that you can accept that type of object from them it deserializes quite nicely.
3. Once you have your Restful API service all setup, you need to update workwave''s systems. The code you have above can be somewhat useful, but you need to use a POST action not a GET action to update their system with your new web service URL. That is how they will contact you by calling the URL that you give to them.

Thats a very high level view, but its really not too bad.


这篇关于如何使用回调网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆