Register
Hello There, Guest!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
V.B || Getting Image URL From API Code!
#1
So ive been working on a easy program for the past couple weeks that can change your desktop background to A.P of the day.

Since its Far Fetching from the URL Code, It'd be highly unlikely that could work for tomorrow or any other day in that matter.

My code from the Api for that image.
Code:
{
  "copyright": "Sergei Makurin",
  "date": "2018-04-03",
  "explanation": "You may have heard of the Seven Sisters in the sky, but have you heard about the Seven Strong Men on the ground? Located just west of the Ural Mountains, the unusual Manpupuner rock formations are one of the Seven Wonders of Russia. How these ancient 40-meter high pillars formed is yet unknown.  The persistent photographer of this featured image battled rough terrain and uncooperative weather to capture these rugged stone towers in winter at night, being finally successful in February of 2014.  Utilizing the camera's time delay feature, the photographer holds a flashlight in the foreground near one of the snow-covered pillars.  High above, millions of stars shine down, while the band of our Milky Way Galaxy crosses diagonally down from the upper left.",
  "hdurl": "https://apod.nasa.gov/apod/image/1804/SevenStrongSky_Makurin_960.jpg",
  "media_type": "image",
  "service_version": "v1",
  "title": "The Milky Way over the Seven Strong Men Rock Formations",
  "url": "https://apod.nasa.gov/apod/image/1804/SevenStrongSky_Makurin_960.jpg"
}  

Here is the code I was getting to get the link to the image, I have starred out the actual api address, after all, that's supposed to stay private to you only.
Code:
Dim request As WebRequest = WebRequest.Create("https://api.nasa.gov/planetary/apod?api_key=*************")
   Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
   Dim datastream As Stream = response.GetResponseStream
   Dim reader As New StreamReader(datastream)
   Dim strData As String = reader.ReadToEnd
   Dim pos1 As Long = InStr(strData, """hdurl"": """)
   Dim pos2 As Long = InStr(pos1 - 2, strData, ".jpg", vbTextCompare)
   Dim strLink As String = strData.Substring(pos1 + 9, pos2 - pos1 - 6)
Lifetime supporter & Lifetime member for:  

Special Thanks to, @Sora & @retslac

[Image: agmalogo_a.png]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)