我想了一个解决方法,有些人可能不认为这是一个解决方案,但在我的情况下工作正常,因为它取决于 ISSUU 发布者帐户。解决方案本身正在向与我正在寻找的发布者帐户连接的 ISSUU API 发出请求。
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://api.issuu.com/query?action=issuu.documents.list" +
"&apiKey=Inser Your API Key" +
"&format=json" +
"&documentUsername=User of the account you want to make a request" +
"&pageSize=100&resultOrder=asc" +
"&responseParams=name,documentId,pageCount" +
"&username=Insert your ISSUU username" +
"&token=Insert Your Token here");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "application/json";
try
{
using (WebResponse response = request.GetResponse())
{
var responseValue = string.Empty;
// grab the response
using (var responseStream = response.GetResponseStream())
{
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
if (responseValue != "")
{
List<string> lista_linkss = new List<string>();
JObject ApiRequest = JObject.Parse(responseValue);
//// get JSON result objects into a list
IList<JToken> results = ApiRequest["rsp"]["_content"]["result"]["_content"].Children()["document"].ToList();
for (int i = 0; i < results.Count(); i++)
{
Folheto folheto = new Folheto();
folheto.name = results[i]["name"].ToString();
folheto.documentId = results[i]["documentId"].ToString();
folheto.pageCount = Int32.Parse(results[i]["pageCount"].ToString());
string _date = Newtonsoft.Json.JsonConvert.SerializeObject(results[i]["uploadTimestamp"], Formatting.None, new IsoDateTimeConverter() { DateTimeFormat = "yyyy-MM-dd hh:mm:ss" }).Replace(@"""", string.Empty);
folheto.uploadTimestamp = Convert.ToDateTime(_date);
if (!lista_nomes_Sirena.Contains(folheto.name))
{
list.Add(folheto);
}
}
}
}
}
catch (WebException ex)
{
// Handle error
}
您必须注意参数“pageSize” API 允许的最大值为 100,这意味着您获得的最大结果数为 100,因为我关注的帐户大约有 240 个 pdf,我使用了这个请求一次参数“resultOrder = asc”和另一个时间值“resultOrder=desc”。
这使我可以插入前 100 个 pdf 和最新的 100 个 pdf。由于我不需要历史记录,而只需要他们从现在开始发送的 pdf,因此并没有什么不同。
完成我的代码,我将所有文档的 ID 发送到我创建的 sql 数据库,当我启动程序时,我检查 ID 是否已经下载,如果没有,它会下载 pdf,如果是,它没有吨。
希望有人能发现这项工作有用