Skip to content

Instantly share code, notes, and snippets.

Created May 21, 2015 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d8c3fc4c936466427315 to your computer and use it in GitHub Desktop.
Save anonymous/d8c3fc4c936466427315 to your computer and use it in GitHub Desktop.
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