Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
static Pixiv api_get(string api_str, string param)
{
string query = param;
byte[] queryDataBytes = Encoding.ASCII.GetBytes(query);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://public-api.secure.pixiv.net/v1/" + api_str + ".json" + query);
req.Method = "GET";
req.ContentType = "application/x-www-form-urlencoded";
req.Referer = "http://spapi.pixiv.net/";
req.UserAgent = "PixivIOSApp/5.1.1";
req.Headers.Add("Authorization", "Bearer " + token);
req.CookieContainer = new CookieContainer();
req.CookieContainer.Add(new Uri("https://public-api.secure.pixiv.net"), new Cookie("PHPSESSID", sessid));
WebResponse res = req.GetResponse();
Stream resStream = res.GetResponseStream();
StreamReader sr = new StreamReader(resStream, enc);
string json = sr.ReadToEnd();
Pixiv apires;
apires = JsonConvert.DeserializeObject<Pixiv>(json);
return apires;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.