Created
May 21, 2015 08:53
-
-
Save anonymous/d8c3fc4c936466427315 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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