2014-02-20 4 views
0

vk를 Android 애플리케이션에 통합하려고합니다. 이를 위해이 링크에서 다음 지침을 따르려고합니다. Vk integration .상태를 게시 할 때 오류가 발생했습니다.

나는이 코드로 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.java의 1천2백번째 라인에서

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

다음 코드가 정의된다.

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; 
    } 

이유는 무엇입니까 :

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 방법

은 다음과 같이 정의된다? 이 오류를 근절하도록 도와 주시겠습니까? 나를 도왔다

+0

포스트는 일부 코드 – Merlevede

+0

@osimer pothe가'createWallPost을 게시하시기 바랍니다하시기 바랍니다()'. 오류가 발생하지만 게시물이 실제로 vkontakte 벽에 나타 납니까? – mangusta

+0

CreateWallPost() 코드를 게시했습니다. 그것을 확인하십시오 –

답변

1

직접 VK 안드로이드 SDK를 사용할 수있다 것이 도움이 될 것입니다 바랍니다. 나는 VKShareDialog을 사용한다.

new VKShareDialogBuilder().setText("Title share") 
          .setAttachmentImages(new VKUploadImage[]{new VKUploadImage(bitmap, VKImageParameters.pngImage())}) 
          .setAttachmentLink("Link title", myURL) 
          .setShareDialogListener(new VKShareDialog.VKShareDialogListener() { 
            public void onVkShareComplete(int postId) { 
             Toast.makeText(context, "Shared sucessfully", Toast.LENGTH_SHORT).show(); 
            } 

            public void onVkShareCancel() { 
             Toast.makeText(context, "Share cancelled", Toast.LENGTH_SHORT).show(); 
            } 

            @Override 
            public void onVkShareError(VKError error) { 
             Toast.makeText(context, "Failed to share", Toast.LENGTH_SHORT).show(); 
            } 
           }) 
         .show(activity.getSupportFragmentManager(), "VK_SHARE_DIALOG"); 

벽에 게시하려면, 당신은 몇 가지 권한이 필요합니다

VKSdk.login(ActivityLogin.this,VKScope.FRIENDS,VKScope.WALL,VKScope.PHOTOS); 
0

:

api.createWallPost을 (account.user_id, 메시지, NULL, NULL, 거짓, 거짓, 거짓, NULL, NULL, 새로운 롱 (0), 새로운 롱 (0) null, null);

난 당신이

관련 문제