How to check if a flickr url is valid - flickr

We need the user to be able to enter URLs in our media section . However since users can make mistakes in entering the URLs , we need to ensure that the URLs are valid flickr URLs .
Valid URL eg :
http://www.flickr.com/photos/53067560#N00/sets/72157606175084388/
Invalid URL eg :
http://www.flickr.com/photos/53067560#N00/sets/12345/
Flickr offers API services , but I could not find one that would validate a URL .

The easiest way would be to make a HTTP HEAD request to the url, which would mean the URL is valid if it returns a HTTP response code of 200.
You could also use regex to ensure that it matches the expected pattern, which would possibly cut down the amount of requests you would have to make.

You could make an http HEAD request to the URL and check the http response code. Any response code greater than or equal to 200 and less than 300 is ok. In all likelyhood good URLs will return 200 code.

I am pretty sure you can at least use `flickr.photos.getInfo' to see if the photo in question exists. The rest of the URL can be validated according to the result received.
You can't check for every possible permutation of course but when it comes to photo id, I am pretty certain you can rely on Flickr API... or else, they would be in trouble themselves, no?
Of course, you can double-check by issuing an HTTP GET request on the URL and verify that the result HTTP code is something like 200 (or maybe something >=200 & <=300).

Related

Serving a HTTP request response as a dialog response - Composer Framework

We are developing a chatbot to handle internal and external processes for a local authority. We are trying to display contact information for a particular service from our api endpoint. The HTTP request is successful and delivers, in part, exactly what we want but there's still some unnecessary noise we can't exclude.
We specifically just want the text out of the response ("Response").
Logically, it was thought all we need to do is drill down into ${dialog.api_response.content.Response} but that fails the HTTP request and ${x.content} returns successful but includes Tags, response and the fields within 1.
Is there something simple we've missed using composer to access what we're after or do we need to change the way our endpoint is responding 2? Unfortunately the MS documentation for FrwrkComp is lacking to say the very least.
n.b. The response is currently set up as a (syntactically) SSML response, this is just a test case using an existing resource.
Response in the Emulator
Snippet from FwrkComp
Turns out it was the first thing I tried just syntactically correct. For the case of the code given it was as simple as:
${dialog.api_response.content[0].Response}

Query Sharepoint Online using REST API and passing the query in the body (POST)

The URL length limit is causing me issues when I call the end point /_api/Web/Lists/getByTitle('ListName')/items: if I have too many parameters, the URL length is too long and my request is not treated.
I know we can pass a CAML query to the endpoint /_api/Web/Lists/getByTitle('ListName')/GetItems in the body, but this endpoint is limited if we want to expand a lookup/user field. So I'm stuck with /items.
Is there a way to do a POST to /_api/Web/Lists/getByTitle('ListName')/items with passing the parameters in the body instead of passing them in the URL? If yes, how? I didn't find anything on the web about it…
Thanks
It looks like we can use the $batch endpoint to do it, even if it's not really the same, but I guess it will work… If someone knows another way, please share!
Note: for an unknown reason I have a $batch that returns Invalid request., but if I pass the same URL to a normal request, then it works…

QR code best approach for POST request from REST API

I'm setting up a website that will be mobile focused and one of the features I wan't to implement is users to be able to log an entry by just scanning a QR code.
For what I read is not really possible to make a POST request directly from a QR code, so I was thinking in two different options:
1. Make a GET request and then redirect that inside my server to a POST route in my routes.
So the URL would be something like https://example.com/user/resources/someresourceid123/logs/new and then this would create a POST request to https://example.com/user/resources/someresourceid123/logs/ and create the new entry to then send a response to the user but I'm not really sure this is the best approach or if it's possible at all.
My POST request only requires the resourceid which I should be able to get from req.params and the userid which I get from my req.user.
2. Do my logic and log the entry to my DB using the GET request to https://example.com/user/resources/someresourceid123/logs/new.
This would mean that my controller for that request will do everything needed from the GET request without having to make an additional POST request afterwards. I should be able to get both the resourceid and userid from the req object but not sure if being a GET request limits what I can do with it.
If any of those are possible, which would be the best approach?
I'd propose to go with a second option simply for the sake of performance. But you need to make sure your requests are not cached by any proxy, which is usually the case with GET requests.

Handle custom URL portion after /

I am honestly not sure what it is called, however hopefully someone here knows how and what exactly it is.
I want to be able to handle a URL sent to my server, and display different site based on the URL. Such as facebook and twitter do, (i.e. facebook.com/usernamehere) I assume that the server takes that link and parses to load the right information based on the URL, but I am not exactly sure what that is called or how I can achieve that effect.

Get Request URL Capability

I recently began working with JavaScript and am looking at various get and post requests one can send to a server.
For get, as far as I know, all of the information of the query is contained in the URL that the user triggers. On the server side this has to be dissected to retrieve the necessary parameters.
I was just wondering how larger and more detailed requests are handled with this get method? For instance what if I had millions and millions of parameters that make up my whole request? Would they all be jumbled into the URL? Is there a limit as to the number of unique URLs one can have? I read this post:
How do URL shorteners guarantee unique URLs when they don't expire?
I would really like some more input.
Thank You!

Resources