2

I am making a app using google Fact Check API and and the response json is like this

{
  "claims": [
    {
      "text": "“President El-Sisi confirmed Egypt's unwavering strategic position on Libya, which aimed at restoring stability in the country, preserving its national institutions, and preventing further deterioration in Libya’s security situation via curbing illegal foreign interference in the Libyan issue.”",
      "claimant": "Abdel-Fattah al-Sisi",
      "claimDate": "2020-07-24T00:00:00Z",
      "claimReview": [
        {
          "publisher": {
            "name": "POLYGRAPH.info",
            "site": "polygraph.info"
          },
          "url": "https://www.polygraph.info/a/egypt-libya-sisi-intervention/30745850.html",
          "title": "Egypt's al-Sisi Told Trump Foreign Interference in Libya is Bad – Just as his Parliament Authorized him to Intervene",
          "reviewDate": "2020-07-24T00:00:00Z",
          "textualRating": "Misleading",
          "languageCode": "en"
        }
      ]
    }
  ],
  "nextPageToken": "CAE"
}

I want to know how can i get the urls image and display it like this image

I can't seem to figure out how to get the image as in the JSON there is only url of the webpage.

Edit:- Here is the code in which i am using GSON to store the values

JsonObjectRequest jsonObjectRequest = new JsonObjectRequest
                (Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
                    @Override
                    public void onResponse(JSONObject response) {

                        Log.i("response",response.toString());
                        Search search = gson.fromJson(response.toString(),Search.class);
                        Log.i("response",search.toString());
                        textView.setText("Claim:- "+search.claims.get(0).text+"\nFactual Rating:-"+search.claims.get(0).claimReview.get(0).textualRating);

                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Log.i("response",error.toString());// TODO: Handle error

                    }
                });
Shubham
  • 23
  • 6
  • JSONObject https://developer.android.com/reference/org/json/JSONObject is helpful for you in this case. – TaQuangTu Jul 26 '20 at 06:25
  • how do you get the json data in the first place, can you share the code? as I can read from the docs there should be fields for some image urls -> [link](https://developers.google.com/fact-check/tools/api/reference/rest/v1alpha1/pages). is it always the same page or a random one? – Felix Jul 26 '20 at 08:20
  • 1
    @Felix the docs you are referring to are for fact-checking websites but not for the end user. [link](https://developers.google.com/search/docs/data-types/factcheck), as for the code I have edited it. – Shubham Jul 26 '20 at 12:51
  • @TaQuangTu I know how to use JSONObject the problem here is getting the link of the image when there is no link to the image in the json, so i need to know a way to get the image from a webpage directly. – Shubham Jul 26 '20 at 12:52
  • when you know the exact website you can use a web scraper it for: [link](https://stackoverflow.com/questions/2835505/how-to-scan-a-website-or-page-for-info-and-bring-it-into-my-program/2835555#2835555) – Felix Jul 26 '20 at 13:04
  • perfect, i write it as an answer for other people – Felix Jul 26 '20 at 15:35

1 Answers1

1

If you know the exact website you can use a web scraper. Look how you can do it here.

Felix
  • 284
  • 2
  • 12