R
R
Ruslan_P2017-03-04 09:34:40
In contact with
Ruslan_P, 2017-03-04 09:34:40

How to get the text of the wiki page in the context using Android Studio and vk sdk?

Hello! I am writing a java application in Android Studio using the VK SDK. The group has a wiki page, you need to get its text. I use this get-request method https://vk.com/dev/pages.get in the parameters I send the id of the page owner, the id of the page, the need_source flag, which actually returns the text, and the site_preview flag (without it, the method fails).

textView = (TextView) findViewById(R.id.textView);
 
                VKRequest request = new VKRequest("pages.get", VKParameters.from("owner_id", 289807139, "page_id", 52394462, "site_preview", 1, "need_source", 1));
 
                Log.d(LOG_TAG, request.toString());
 
                request.executeWithListener(new VKRequest.VKRequestListener() {
                    @Override
                    public void onComplete(VKResponse response) {
                        super.onComplete(response);
 
                        Log.d(LOG_TAG, response.responseString);
 
                        try {
                            JSONObject jsonObject = response.json.getJSONObject("response");
                            VKApiWikiPage vkApiWikiPage = new VKApiWikiPage();
                            vkApiWikiPage.parse(jsonObject);
 
                            textView.setText(vkApiWikiPage.source);
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
 
                    @Override
                    public void onError(VKError error) {
                        super.onError(error);
 
                        Log.d(LOG_TAG, error.toString());
                    }
                });

The problem is that the method returns empty title and source fields, which should contain string values ​​for the page's title and text. The request contains this:
{pages.get owner_id=289807139 page_id=52394462 site_preview=1 need_source=1 }
And the response contains this:
{"response":{"id":52394462,"group_id":0,"owner_id" :289807139,"title":"","edited":0,"created":0,"views":0,"url":null,"source":"","view_url":"https:\/ \/m.vk.com\/article289807139_52394462?api_view=c436bb6572d73f9d5357a70a0465c8〈=en"}
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question