Hi, everyone!
Okay, so, I'm kinda mad that I got stuck on something like that, since I feel like the answer is going to be simple, but I just can't find it.
Basically, we have a little school project where we have to use APIs. I'm combining apixu (a weather api) to flickr. (Apixu contains a <text> object in its XML file, it's a string that contains "Sunny" or "Mist", or any adjective like that.)
I'm gonna use flickr's API with that tag at the end of the URL to find related pictures and display them. But I seem to have two problems :
First, I can't find how to link the <text> item from apixu into the flickr link.
Second, even if I hard-code a tag into the link (like, say, "Sunny"), the image doesn't display, even though I did manage to succesfully display a working URL for a jpg image as a string.
Edit : the error log also gave me these informations :
(Fetch error) URL is invalid (ErrorCode=12005) (illustro\Weather\Weather.ini - [MesureImageURL])
So, if anyone knows what part of the code is broken, or if you have any idea, I'd be glad to hear them! Thanks in advance. Here's a link to the code (it's only one .ini file that I put in illustro).
https://www.mediafire.com/file/u55899xpulhpkrx/Weather.ini/file
It is currently April 19th, 2024, 9:27 am
Help : Displaying an image from Flickr's API
-
- Posts: 4
- Joined: October 25th, 2018, 2:16 pm
-
- Posts: 919
- Joined: January 30th, 2017, 2:01 am
- Location: Greece
Re: Help : Displaying an image from Flickr's API
Hello,Salad Puncher wrote: ↑October 25th, 2018, 2:39 pm Hi, everyone!
Okay, so, I'm kinda mad that I got stuck on something like that, since I feel like the answer is going to be simple, but I just can't find it.
Basically, we have a little school project where we have to use APIs. I'm combining apixu (a weather api) to flickr. (Apixu contains a <text> object in its XML file, it's a string that contains "Sunny" or "Mist", or any adjective like that.)
I'm gonna use flickr's API with that tag at the end of the URL to find related pictures and display them. But I seem to have two problems :
First, I can't find how to link the <text> item from apixu into the flickr link.
Second, even if I hard-code a tag into the link (like, say, "Sunny"), the image doesn't display, even though I did manage to succesfully display a working URL for a jpg image as a string.
Edit : the error log also gave me these informations :
(Fetch error) URL is invalid (ErrorCode=12005) (illustro\Weather\Weather.ini - [MesureImageURL])
So, if anyone knows what part of the code is broken, or if you have any idea, I'd be glad to hear them! Thanks in advance. Here's a link to the code (it's only one .ini file that I put in illustro).
https://www.mediafire.com/file/u55899xpulhpkrx/Weather.ini/file
This is the link that I get from
[MesurePhotos]
https://api.flickr.com/services/rest?api_key=af343a2bd7b1f547e79699422d54d993&method=flickr.photos.search&tags=//cdn.apixu.com/weather/64x64/day/116.png
What do you want to achieve from here?
Because the RegExp you have for this link is:
RegExp="(?siU)<photo id="([^"]*)" owner="([^"]*)" secret="([^"]*)" server="([^"]*)" farm="([^"]*)" title=(.*)>"
which doesn't work for this link.
Also change the link to:
Url="https://api.flickr.com/services/rest?api_key=af343a2bd7b1f547e79699422d54d993&method=flickr.photos.search&tags= [&MesureImageApixu:]"
and try another RegExp
-
- Posts: 4
- Joined: October 25th, 2018, 2:16 pm
Re: Help : Displaying an image from Flickr's API
Thanks! Unfortunately, that wasn't a full fix, but there was some progress.
No more errors, so the URL should be valid. The pic still doesn't display, but I'll double check the MeterImage doc for that.
Still, thanks! I'll keep trying to work it out.
Edit : oh, sorry, I didn't notice the edit. Uh, yeah, the link was wrong because I used index 7 instead of index 6, I didn't count properly.
No more errors, so the URL should be valid. The pic still doesn't display, but I'll double check the MeterImage doc for that.
Still, thanks! I'll keep trying to work it out.
Edit : oh, sorry, I didn't notice the edit. Uh, yeah, the link was wrong because I used index 7 instead of index 6, I didn't count properly.
-
- Posts: 919
- Joined: January 30th, 2017, 2:01 am
- Location: Greece
Re: Help : Displaying an image from Flickr's API
Oh okay, do you still have issues or did you fix it? If you still have issues, share the correct link and regexp for the [MesurePhotos] for further help.Salad Puncher wrote: ↑October 25th, 2018, 4:23 pm Thanks! Unfortunately, that wasn't a full fix, but there was some progress.
No more errors, so the URL should be valid. The pic still doesn't display, but I'll double check the MeterImage doc for that.
Still, thanks! I'll keep trying to work it out.
Edit : oh, sorry, I didn't notice the edit. Uh, yeah, the link was wrong because I used index 7 instead of index 6, I didn't count properly.
-
- Rainmeter Sage
- Posts: 16144
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Help : Displaying an image from Flickr's API
As kyriakos876 well said, you have to add a & simbol into the measures name used as section variable into a URL (last paragraph here). The colon isn't needed I think.
With this update, the URL option of [MesurePhotos] measure become: Url=https://api.flickr.com/services/rest?api_key=af343a2bd7b1f547e79699422d54d993&method=flickr.photos.search&tags=[&MesureImageApixu].
However the [MesureImageApixu] returns a URL of an image (right now: //cdn.apixu.com/weather/64x64/day/116.png). This image can be downloaded and used. But the concatenated URLs doesn't work. I can't figure out what the complete and correct URL option of the [MesurePhotos] measure would be. What would it be? Do you have an example of a valid site?
Two more errors of the code:
But this still doesn't fix all issues and the skin keeps not working. There are more error messages. First we have to figure out what the URL option of the [MesurePhotos] measure would be (see above).
With this update, the URL option of [MesurePhotos] measure become: Url=https://api.flickr.com/services/rest?api_key=af343a2bd7b1f547e79699422d54d993&method=flickr.photos.search&tags=[&MesureImageApixu].
However the [MesureImageApixu] returns a URL of an image (right now: //cdn.apixu.com/weather/64x64/day/116.png). This image can be downloaded and used. But the concatenated URLs doesn't work. I can't figure out what the complete and correct URL option of the [MesurePhotos] measure would be. What would it be? Do you have an example of a valid site?
Two more errors of the code:
- The DownloadFile=1 option of the [MesureImageURL] measure would be Download=1. With the DownloadFile option you set a relative path of the downloaded file, but the WebParser measure by default doesn1t download file, to do this, you have to set its Download option to 1.
- A URL=https://farm%5.staticflickr.com/%4/%1_%3.jpg option is completely wrong (same [MesureImageURL] measure). You can't use the MeasureName options as you did into a WebParser measure. This approach works on a String meter, for example, but not on a WebParser measure. Instead, this option would be: URL=https://farm[&MesureFlickrFarm].staticflickr.com/[&MesureFlickrServer]/[&MesureFlickrId]_[&MesureFlickrSecret].jpg. This also requires to set up the dynamic variables, through the DynamicVariables=1 option.
With these changes, the measure would be:(see that I commented out all MeasureName options).Code: Select all
[MesureImageURL] Measure=WebParser ;MeasureName=MesureFlickrId ;MeasureName2=MesureFlickrOwner ;MeasureName3=MesureFlickrSecret ;MeasureName4=MesureFlickrServer ;MeasureName5=MesureFlickrFarm URL=https://farm[&MesureFlickrFarm].staticflickr.com/[&MesureFlickrServer]/[&MesureFlickrId]_[&MesureFlickrSecret].jpg DynamicVariables=1 Download=1
But this still doesn't fix all issues and the skin keeps not working. There are more error messages. First we have to figure out what the URL option of the [MesurePhotos] measure would be (see above).
-
- Posts: 4
- Joined: October 25th, 2018, 2:16 pm
Re: Help : Displaying an image from Flickr's API
Well, I guess you pretty much just saved me there. I don't recall finding any doc about needing an "&", neither would I ever have figured that we need to temporarly disable measures.
The reason you found that the code still didn't work was what I explained in my edit earlier : [MesureImageApixu] was referring to the wrong StringIndex (I had put 7 instead of 6, that's a really silly mistake). But once that's fixed, the code does work!
Thank you very much to both of you for taking the time to explain, I really appreciate it!
The reason you found that the code still didn't work was what I explained in my edit earlier : [MesureImageApixu] was referring to the wrong StringIndex (I had put 7 instead of 6, that's a really silly mistake). But once that's fixed, the code does work!
Thank you very much to both of you for taking the time to explain, I really appreciate it!
-
- Rainmeter Sage
- Posts: 16144
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Help : Displaying an image from Flickr's API
Last paragraph here.Salad Puncher wrote: ↑October 26th, 2018, 6:32 am I don't recall finding any doc about needing an "&",
When you want to use the value returned by a WebParser measure into any other type of measure, usually you have to disable the second measure, then enable it when the WebParser measure got its value, because when the skin is refreshed / loaded, the WebParser measure is empty and it needs a time to firstly get the value. But in meantime being empty, it usually gives an error message in log. But in meantime the WebParser measure being empty, it usually gives an error message in log. That's why I usually recommend to disable / enable procedure.Salad Puncher wrote: ↑October 26th, 2018, 6:32 am neither would I ever have figured that we need to temporarly disable measures.
Don't worry, it happens to all of us sometimes. At least you've figured out what was the mistake.Salad Puncher wrote: ↑October 26th, 2018, 6:32 am (I had put 7 instead of 6, that's a really silly mistake).