SciTS Mendeley 小组目前有 1205 个资源(引用)。但是,无论我们如何调用 API 的“getDocuments”方法,我们都只能获取前 1000 个资源。我们需要传递一个特定的参数来获取完整的资源列表吗?或者有没有办法进行后续调用以获取第一次调用未返回的数据页?
string grantType = "client_credentials"; string applicationID = "id"; string clientsecret = "XXXXXXX"; string redirecturi = "*******"; string url = "https://api-oauth2.mendeley.com/oauth/token"; string view = "all"; string group_id = "f7c0e437-f68b-34df-83c7-2877147ba8f9"; HttpWebResponse response = null; try { // Create the data to send StringBuilder data = new StringBuilder(); data.Append("client_id=" + Uri.EscapeDataString(applicationID)); data.Append("&client_secret=" + Uri.EscapeDataString(clientsecret)); data.Append("&redirect_uri=" + Uri.EscapeDataString(redirecturi)); data.Append("&grant_type=" + Uri.EscapeDataString(grantType)); data.Append("&response_type=" + Uri.EscapeDataString("code")); data.Append("&scope=" + Uri.EscapeDataString("all")); byte[] byteArray = Encoding.UTF8.GetBytes(data.ToString()); // Setup the Request HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = byteArray.Length; // Write data Stream postStream = request.GetRequestStream(); postStream.Write(byteArray, 0, byteArray.Length); postStream.Close(); // Send Request & Get Response response = (HttpWebResponse)request.GetResponse(); string accessToken; using (StreamReader reader = new StreamReader(response.GetResponseStream())) { // Get the Response Stream string json = reader.ReadLine(); Console.WriteLine(json); // Retrieve and Return the Access Token JavaScriptSerializer ser = new JavaScriptSerializer(); Dictionary<string, object> x = (Dictionary<string, object>)ser.DeserializeObject(json); accessToken = x["access_token"].ToString(); } // Console.WriteLine("Access TOken"+ accessToken); var apiUrl = "https://api-oauth2.mendeley.com/oapi/documents/groups/3556001/docs/?details=true&items=1250"; try { request = (HttpWebRequest)WebRequest.Create(apiUrl); request.Method = "GET"; request.Headers.Add("Authorization", "Bearer " + accessToken); request.Host = "api-oauth2.mendeley.com"; response = (HttpWebResponse)request.GetResponse(); using (StreamReader reader = new StreamReader(response.GetResponseStream())) { // Get the Response Stream string json = reader.ReadLine(); Console.WriteLine(json); //need this to import documents } } catch (WebException ex1) { Console.WriteLine("Access TOken exception" + ex1.Message); } } catch (WebException e) { if (e.Response != null) { using (HttpWebResponse err = (HttpWebResponse)e.Response) { Console.WriteLine("The server returned '{0}' with the status code '{1} ({2:d})'.", err.StatusDescription, err.StatusCode, err.StatusCode); } } }
问问题
139 次