0

Android アプリケーションに vk を統合しようとしています。このために、このリンクの次の指示に従おうとしています。Vk 統合。

このコードで vk に正常にログインできました。しかし、自分のウォールにステータスを投稿しようとした後、次のエラーが表示されました。

02-20 14:08:54.779: W/System.err(2945): java.lang.NullPointerException
02-20 14:08:54.789: W/System.err(2945):     at com.perm.kate.api.Api.createWallPost(Api.java:1200)
02-20 14:08:54.789: W/System.err(2945):     at com.perm.kate.api.sample.MainActivity$5.run(MainActivity.java:100)

MainActivity.java の 100 行目に次のコードが定義されています。

api.createWallPost(account.user_id, text, null, null, false, false, false, null, null, null, null, null, null);

API.java の 1200 行目に次のコードが定義されています。

public WallMessage repostWallPost(String object, String message, Long gid, String captcha_key, String captcha_sid) throws IOException, JSONException, KException{
        Params params = new Params("wall.repost");
        params.put("group_id", gid);
        params.put("message", message);
        params.put("object", object);
        addCaptchaParams(captcha_key, captcha_sid, params);
        JSONObject root = sendRequest(params);
        JSONObject response = root.getJSONObject("response");
        WallMessage wall=new WallMessage(); 
        wall.id = response.optLong("post_id");
        wall.like_count=response.optInt("likes_count");
        wall.reposts_count=response.optInt("reposts_count");
        return wall;
    }

createwallpost のメソッドは次のように定義されます。

public long createWallPost(long owner_id, String text, Collection<String> attachments, String export, boolean only_friends, boolean from_group, boolean signed, String lat, String lon, Long publish_date, Long post_id, String captcha_key, String captcha_sid) throws IOException, JSONException, KException{
        Params params = new Params("wall.post");
        params.put("owner_id", owner_id);
        params.put("attachments", arrayToString(attachments));
        params.put("lat", lat);
        params.put("long", lon);
        params.put("message", text);
        if(export!=null && export.length()!=0)
            params.put("services",export);
        if (from_group)
            params.put("from_group","1");
        if (only_friends)
            params.put("friends_only","1");
        if (signed)
            params.put("signed","1");
        params.put("publish_date", publish_date);
        if (post_id > 0)
            params.put("post_id", post_id);
        addCaptchaParams(captcha_key, captcha_sid, params);
        JSONObject root = sendRequest(params, true);
        JSONObject response = root.getJSONObject("response");
        long res_post_id = response.optLong("post_id");
        return res_post_id;
    }

理由は何ですか ?このエラーを根絶するのを手伝ってくれませんか?

4

2 に答える 2

0

それは私を助けました:

api.createWallPost(account.user_id, message, null, null, false, false, false, null, null, new Long(0), new Long(0), null, null);

お役に立てば幸いです

于 2014-05-07T13:04:41.683 に答える