c# - Load images with date criteria from Instagram -


i have code loads images instagram.

public string giveinstagramimage()     {         string strtagname = "snowy";         string straccesstoken = "<<redacted>>";         string nextpageurl = null;         string imageurl = null;                 {             webrequest webrequest = null;             if (webrequest == null && string.isnullorempty(nextpageurl))                 webrequest = httpwebrequest.create(string.format("https://api.instagram.com/v1/tags/{0}/media/recent?access_token={1}", strtagname, straccesstoken));             else                 webrequest = httpwebrequest.create(nextpageurl);              var responsestream = webrequest.getresponse().getresponsestream();             encoding encode = system.text.encoding.default;             using (streamreader reader = new streamreader(responsestream, encode))             {                 jtoken token = jobject.parse(reader.readtoend());                 var pagination = token.selecttoken("pagination");                 if (pagination != null && pagination.selecttoken("next_url") != null)                 {                     nextpageurl = pagination.selecttoken("next_url").tostring();                 }                 else                 {                     nextpageurl = null;                 }                 var images = token.selecttoken("data").toarray();                 foreach (var image in images)                 {                     imageurl = image.selecttoken("images").selecttoken("standard_resolution").selecttoken("url").tostring();                     if (string.isnullorempty(imageurl))                         console.writeline("broken image url");                      var imageresponse = httpwebrequest.create(imageurl).getresponse().getresponsestream();                      var imageid = image.selecttoken("id");                     return imageurl;                 }             }         }         while (!string.isnullorempty(nextpageurl));         return imageurl;     } 

currently instagram api gives me top 20 images. need load images last 30 days.

how can it?

the tag endpoint accepts count parameter. if set count parameter greater 33, return 33 images on every call , using pagination can continue rest of images.

webrequest = httpwebrequest.create(string.format("https://api.instagram.com/v1/tags/{0}/media/recent?access_token={1}&count=100000", strtagname, straccesstoken)); 

to load images last 30 days, set count high value , check created_time property of each image stop wherever like.

var imagecreatedtime = image.selecttoken("created_time"); 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -