i have integrated the Flickr search in my java application using scribe. I am using the
flickr.photos.search
api call to get a json object as response. But after i am parsing the json object to get the url and i am testing the url . i am getting the following .gif image.
i am getting the josn response correctly then i am using this URL FORMAT
to parse the URL.
Please tell me whether this is an api problem or am i doing something wrong ??
The urls generated by me are correct since i have checked it using the flickr api explorer in the site itself.
Found my problem was not placing a .jpg at the end of the URL. So much for that..
Related
I ma using SpringBoot and Java. I would like to get data from a website. The website has autocomplete box that returns data in a browser. I would like access this data. What is the easiest way to do this in Java? Is this possible?
I try use the url in Postman using a GET request, but I get a 403 error.
e.g. https://www.booking.com/autocomplete_csrf?v=1&lang=en-gb&sid=2939ff8d1a04c7dcecd8206f31a3481e&aid=304142&pid=3ce829a2434a0089&stype=1&src=index&eb=0&e_obj_labels=1&e_tclm=1&e_smmd=2&e_ms=1&e_msm=1&e_themes_msm_1=1&add_themes=1&themes_match_start=1&include_synonyms=1&sort_nr_destinations=1&gpf=1&term=Lond&_=1675662919991
If you look at booking.com, there is an autocomplete box.
I have PHP script on the server side which executes the SQL query and produces a JSON string from it. But how do I get that code to execute to then retrieve and decode the JSON on the Android app?
I am quite new to android so as much help would be very appreciated.
I can't write you the whole tutorial but i can give you a to-do list which you can check your progress.
Your application to generate JSON script in txt, or real time response.
Setup your backend server(you have sql server already and also PHP, so i guess you have set it up already, probably WAMP or similar), which is the endpoint/url path to generate the response required, in this case your JSON response.
Check the API is working or not by using "advanced rest client" or simple type your endpoint in browser, if you can get the correct response from it, the API is working as expected.
Created your android app, with simple HTTP request/response, send a HTTP request to the url/path you setup, see if you can get the JSON response or not.
Please comment here if you need further details, this is relatively easy and should be able to finished in 1 day for beginner.
Checking the extension of the file works in most cases, but not for all. Consider the following link:
http://t0.gstatic.com/images?q=tbn:ANd9GcTqqcX4SsdwgithvRcjQl_W3Hj-eIc_12FvdeGS2sO31uZ0F1HHqcdRKNo
Can I check from the URL if it is a link to an image? If not, is there a way to check after the page has loaded in the webview?
I know that I could download every page using HttpURLConnection, but I'm trying to avoid that approach.
Check Response HTTP Header Content-Type. It will be one of the image types. For Example, if I open the URL you have provided in Browser, will see Content-Type as show below
Content-Type:image/jpeg
You can use HttpHead method to fetch just the headers
Recently I have been trying to learn Semantic Web. For a project I need to retrieve data from a given dbPedia link. e.g http://dbpedia.org/page/Berlin . But when retrieve data using java.net.URLConnection I get the html data. How can I get the xml from the same link ? I know that there is link in every dbpedia page to download the XML but that is not what I want to do. Thanks in advance.
Note that the URI of the resource is actually http://dbpedia.org/resource/Berlin (with resource, not page). Ideally, you could request that URI with an Accept header of application/rdf+xml and get the RDF/XML representation of the resource. That's how the BBC publishes their data (e.g., see this answer), but DBpedia doesn't do that. Even if you request application/rdf+xml, you end up getting a redirect. You can see if you try with an HTTP client. E.g., using Advanced Rest Client in Chrome, we get this 303 redirect:
In a web browser, you get redirected to the page version by a 303 See Other response code. Ideally, you could request the resource URI with the accept header set to application/rdf+xml and get the data, but DBpedia doesn't place quite so nicely.
So, that means that the easiest way is to note that at the bottom of http://dbpedia.org/page/Berlin, there's the text with some download links:
RDF ( N-Triples N3/Turtle JSON XML )
The URL of the last link is http://dbpedia.org/data/Berlin.rdf. Thus, you can get the RDF/XML by changing page or resource to data, and appending .rdf to the end of the URL. It's not the most ReSTful solution, but it seems to be what's available.
The good to access data from dbpedia is through Sparql. You can use Apache Jena to run sparql queries against http://dbpedia.org/sparql
There is a link to Google Drive file accessible to anyone without authentication. Is there any way to download that file using just link and some sort of http client? Most of examples around are relying on Drive API and file IDs, however I'd like to stick with more lightweight approach, at the same time no parsing web page that results from http get to the url.
"If you want to share a direct link, simply change the format of the link from this:
drive.google.com/file/d/FILE_ID/edit?usp=sharing
To this:
drive.google.com/uc?export=download&id=FILE_ID
Note that you'll need to grab the file ID from the original link and append it to the end of the new link.
With the new format, any link you share will automatically download to your recipient's computer."
http://lifehacker.com/share-direct-links-to-files-in-google-drive-and-skip-th-1493813665 //Jan 2014