用于检索已发送消息的 bulksms URI
bulksms URI for retrieving messages sent
BulkSMS,从数据范围(>= 或 >)中检索消息,没有强加的限制
Json 可以很好地发送和解析 return 数据,它的提交 URI,我正在努力解决。我正在以正确的格式 return 获取数据,但还不够,所以它不是 URI 格式的过程。
底部代码:
经过一天的有根据的猜测,该 URI 的正确语法应该是什么,并阅读了 api 手册,值得称赞的是,该手册提供了发送 SMS 消息的很好的示例。
我猜这是主要目的。我正在尝试获取我们在某个日期范围内或自某个日期以来发送的邮件列表。
string myURI = "https://api.bulksms.com/v1/messages?filter=submission.date%3E%3D2018-01-01T10%3A00%3A00%2B01%3A00";
编辑 - %3E 等于 > -------- %3D 等于 =
所以这个未编码的意思是自年初以来的所有消息,但是 api 表明消息数量的限制是 1000,好吧,但是他们有一个可以添加的参数要覆盖它,例如 ?limit=3000
当我将此应用到我的 URI 时,我收到错误请求错误 (400),有没有人有一些可能有效的示例?
api 文档:
http://developer.bulksms.com/json/v1/#tag/Message%2Fpaths%2F~1messages%2Fget
干杯
public static string GetListOfSMSMessages(string body)
{
string myURI = "https://api.bulksms.com/v1/messages?filter=submission.date%3E%3D2018-01-01T10%3A00%3A00%2B01%3A00";
string myUsername = "validusername";
string myPassword = "validpassword";
var request = WebRequest.Create(myURI);
request.Credentials = new NetworkCredential(myUsername, myPassword);
request.PreAuthenticate = true;
request.Method = "GET";
request.ContentType = "application/ascii"; //"application/json";
try
{
// make the call to the API
var response = request.GetResponse();
// read the response and add to list
List<string> outlist = new List<string>();
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
while (!reader.EndOfStream)
{
outlist.Add(reader.ReadLine());
}
}
}
catch (WebException ex)
{
// show the general message
Console.WriteLine("An error occurred:" + ex.Message);
// print the detail that comes with the error
var reader = new StreamReader(ex.Response.GetResponseStream());
Console.WriteLine("Error details:" + reader.ReadToEnd());
return "Failed";
}
return "Successful";
这是一个在查询字符串中包含 limit
的工作示例:
using System;
using System.IO;
using System.Net;
using System.Text;
class MainClass
{
public static void Main(string[] args)
{
string myURI = "https://api.bulksms.com/v1/messages?filter=submission.date%3E%3D2018-01-01T10%3A00%3A00%2B01%3A00&limit=2";
string myUsername = "someuser";
string myPassword = "somepassword";
var request = WebRequest.Create(myURI);
request.Credentials = new NetworkCredential(myUsername, myPassword);
request.PreAuthenticate = true;
request.Method = "GET";
request.ContentType = "application/json";
try
{
// make the call to the API
var response = request.GetResponse();
// read the response and print it to the console
var reader = new StreamReader(response.GetResponseStream());
Console.WriteLine(reader.ReadToEnd());
} catch (WebException ex) {
// show the general message
Console.WriteLine("An error occurred:" + ex.Message);
// print the detail that come with the HTTP error
var reader = new StreamReader(ex.Response.GetResponseStream());
Console.WriteLine("Error details:" + reader.ReadToEnd());
}
}
}
BulkSMS,从数据范围(>= 或 >)中检索消息,没有强加的限制
Json 可以很好地发送和解析 return 数据,它的提交 URI,我正在努力解决。我正在以正确的格式 return 获取数据,但还不够,所以它不是 URI 格式的过程。
底部代码:
经过一天的有根据的猜测,该 URI 的正确语法应该是什么,并阅读了 api 手册,值得称赞的是,该手册提供了发送 SMS 消息的很好的示例。
我猜这是主要目的。我正在尝试获取我们在某个日期范围内或自某个日期以来发送的邮件列表。
string myURI = "https://api.bulksms.com/v1/messages?filter=submission.date%3E%3D2018-01-01T10%3A00%3A00%2B01%3A00";
编辑 - %3E 等于 > -------- %3D 等于 =
所以这个未编码的意思是自年初以来的所有消息,但是 api 表明消息数量的限制是 1000,好吧,但是他们有一个可以添加的参数要覆盖它,例如 ?limit=3000
当我将此应用到我的 URI 时,我收到错误请求错误 (400),有没有人有一些可能有效的示例?
api 文档: http://developer.bulksms.com/json/v1/#tag/Message%2Fpaths%2F~1messages%2Fget
干杯
public static string GetListOfSMSMessages(string body)
{
string myURI = "https://api.bulksms.com/v1/messages?filter=submission.date%3E%3D2018-01-01T10%3A00%3A00%2B01%3A00";
string myUsername = "validusername";
string myPassword = "validpassword";
var request = WebRequest.Create(myURI);
request.Credentials = new NetworkCredential(myUsername, myPassword);
request.PreAuthenticate = true;
request.Method = "GET";
request.ContentType = "application/ascii"; //"application/json";
try
{
// make the call to the API
var response = request.GetResponse();
// read the response and add to list
List<string> outlist = new List<string>();
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
while (!reader.EndOfStream)
{
outlist.Add(reader.ReadLine());
}
}
}
catch (WebException ex)
{
// show the general message
Console.WriteLine("An error occurred:" + ex.Message);
// print the detail that comes with the error
var reader = new StreamReader(ex.Response.GetResponseStream());
Console.WriteLine("Error details:" + reader.ReadToEnd());
return "Failed";
}
return "Successful";
这是一个在查询字符串中包含 limit
的工作示例:
using System;
using System.IO;
using System.Net;
using System.Text;
class MainClass
{
public static void Main(string[] args)
{
string myURI = "https://api.bulksms.com/v1/messages?filter=submission.date%3E%3D2018-01-01T10%3A00%3A00%2B01%3A00&limit=2";
string myUsername = "someuser";
string myPassword = "somepassword";
var request = WebRequest.Create(myURI);
request.Credentials = new NetworkCredential(myUsername, myPassword);
request.PreAuthenticate = true;
request.Method = "GET";
request.ContentType = "application/json";
try
{
// make the call to the API
var response = request.GetResponse();
// read the response and print it to the console
var reader = new StreamReader(response.GetResponseStream());
Console.WriteLine(reader.ReadToEnd());
} catch (WebException ex) {
// show the general message
Console.WriteLine("An error occurred:" + ex.Message);
// print the detail that come with the HTTP error
var reader = new StreamReader(ex.Response.GetResponseStream());
Console.WriteLine("Error details:" + reader.ReadToEnd());
}
}
}