通过与C sharp的聊天发送文件
使用C sharp通过聊天发送文件
C sharp : API文档
通过与C sharp的聊天发送文件
String afilnet_class="chat";
String afilnet_method="sendfile";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_platform="whatsapp";
String afilnet_platformid="100";
String afilnet_destination="3460000000";
String afilnet_type="image";
String afilnet_fileurl="https://www.example.com/image.jpg";
String afilnet_thumburl="https://www.example.com/thumb.jpg";
String afilnet_message="test+message";
// Create an URL request
WebRequest request = WebRequest.Create("https://www.afilnet.com/api/http/?class="+afilnet_class+"&method="+afilnet_method+"&user="+afilnet_user+"&password="+afilnet_password+"&platform="+afilnet_platform+"&platformid="+afilnet_platformid+"&destination="+afilnet_destination+"&type="+afilnet_type+"&fileurl="+afilnet_fileurl+"&thumburl="+afilnet_thumburl+"&message="+afilnet_message);
// Get the response
WebResponse response = request.GetResponse ();
// Get the stream returned by the server
Stream dataStream = response.GetResponseStream();
// Open the stream
StreamReader reader = new StreamReader (dataStream);
// Read the Response
String result = reader.ReadToEnd ();
// Asign vars
var data = new NameValueCollection();
data["class"] = "chat";
data["method"] = "sendfile";
data["user"] = "user";
data["password"] = "password";
data["platform"] = "whatsapp";
data["platformid"] = "100";
data["destination"] = "3460000000";
data["type"] = "image";
data["fileurl"] = "https://www.example.com/image.jpg";
data["thumburl"] = "https://www.example.com/thumb.jpg";
data["message"] = "test+message";
// Create Web client
var wb = new WebClient();
// Execute POST petition
var response = wb.UploadValues("https://www.afilnet.com/api/http/", "POST", data);
// Get response
string responseString = Encoding.UTF8.GetString(response);
// Asign vars
var data = new NameValueCollection();
data["class"] = "chat";
data["method"] = "sendfile";
data["platform"] = "whatsapp";
data["platformid"] = "100";
data["destination"] = "3460000000";
data["type"] = "image";
data["fileurl"] = "https://www.example.com/image.jpg";
data["thumburl"] = "https://www.example.com/thumb.jpg";
data["message"] = "test+message";
// Create Web client
var wb = new WebClient { Credentials = new NetworkCredential("user", "password") };
// Execute POST petition
var response = wb.UploadValues("https://www.afilnet.com/api/http/", "POST", data);
// Get response
string responseString = Encoding.UTF8.GetString(response);
String afilnet_class="chat";
String afilnet_method="sendfile";
String afilnet_user="user";
String afilnet_password="password";
String afilnet_platform="whatsapp";
String afilnet_platformid="100";
String afilnet_destination="3460000000";
String afilnet_type="image";
String afilnet_fileurl="https://www.example.com/image.jpg";
String afilnet_thumburl="https://www.example.com/thumb.jpg";
String afilnet_message="test+message";
// Allow SSL/TLS config
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// We create the webservice instance (Register Web Service first in project)
var service = new WebService.ApplicationServicesPortTypeClient();
// Call to WebService method
String response = service.call(afilnet_user, afilnet_password, afilnet_class, afilnet_method, "{\"platform\":\""+afilnet_platform+"\",\"platformid\":\""+afilnet_platformid+"\",\"destination\":\""+afilnet_destination+"\",\"type\":\""+afilnet_type+"\",\"fileurl\":\""+afilnet_fileurl+"\",\"thumburl\":\""+afilnet_thumburl+"\",\"message\":\""+afilnet_message+"\"}");
参数 | 描述 | 必修/可选 |
---|---|---|
class=chat | 要求的课程:要求的课程 | 必修 |
method=sendfile | 请求的类方法:发出请求的类的方法 | 必修 |
user | 您的Afilnet帐户的用户和电子邮件 | 必修 |
password | 您的Afilnet帐户的密码 | 必修 |
platform | 消息发送到的平台。可能的值:“ webchat”,“ whatsapp”,“ telegram”,“ operator” | 必修 |
platformid | 平台识别码 | 必修 |
destination | 文件发送到的收件人 | 必修 |
type | 发送文件的类型。可能的值:“图像”,“视频”,“音频”,“语音”,“文档”,“联系人” | 必修 |
fileurl | 要通过聊天发送的文件所在的网址 | 必修 |
thumburl | 文件随附的缩略图的网址 | 可选的 |
message | 文件附带的消息 | 可选的 |
发出请求时,您将收到以下字段:
- status
-
结果(如果status = success),您将在此处收到以下值:
- 没有其他值会发送给您
- 错误(如果status = error),在这里您将收到错误代码
下面列出了可能的错误代码
码 | 描述 |
---|---|
MISSING_USER | 不包括用户或电子邮件 |
MISSING_PASSWORD | 不包含密码 |
MISSING_CLASS | 不包括课程 |
MISSING_METHOD | 不包括方法 |
MISSING_COMPULSORY_PARAM | 不包括强制参数 |
INCORRECT_USER_PASSWORD | 用户或密码错误 |
INCORRECT_CLASS | 班级不正确 |
INCORRECT_METHOD | 方法不正确 |
CHANNEL_NOT_FOUND | 指定的频道不存在 |
CHAT_NOT_FOUND | 指示的聊天不存在 |
INCORRECT_FILETYPE | 文件类型错误,请检查可能的值 |
INCORRECT_FILEURL | 档案网址无效 |
INCORRECT_THUMBURL | 缩略图的网址无效 |
参数:
- class : chat
- method : sendfile
- user : user
- password : password
- platform : whatsapp
- platformid : 100
- destination : 3460000000
- type : image
- fileurl : https://www.example.com/image.jpg
- thumburl : https://www.example.com/thumb.jpg
- message : test+message
请求:
https://www.afilnet.com/api/http/?class=chat&method=sendfile&user=user&password=password&platform=whatsapp&platformid=100&destination=3460000000&type=image&fileurl=https://www.example.com/image.jpg&thumburl=https://www.example.com/thumb.jpg&message=test+message