如何使用聊天API在Whats App消息中包含和发送图像

时间:2018-10-17 09:15:34

标签: image whatsapp

我的要求是将图像作为Whats App消息发送,我该如何实现?下面是我的代码,我正在使用聊天API。

        message = message.Replace("#", "\n");

        message = "https://upload.wikimedia.org/wikipedia/ru/3/33/NatureCover2001.jpg";

        string param = "phone=91" + phonenumber + "&body=" + message + "&filename=cover.jpg";

        byte[] buffer = System.Text.Encoding.ASCII.GetBytes(param);

        HttpWebRequest WebReq = (HttpWebRequest)WebRequest.Create("https://eu9.chat-api.com/instance7102/message?token=i8ra4a0zlfxwh90b");

        WebReq.Method = "POST";
        WebReq.ContentType = "application/x-www-form-urlencoded";
        WebReq.ContentLength = buffer.Length;
        Stream PostData = WebReq.GetRequestStream();
        PostData.Write(buffer, 0, buffer.Length);
        PostData.Close();

        HttpWebResponse WebResp = (HttpWebResponse)WebReq.GetResponse();

        Stream Answer = WebResp.GetResponseStream();
        StreamReader _Answer = new StreamReader(Answer);
        string response = _Answer.ReadToEnd();

        return response;

0 个答案:

没有答案