2012-06-15 3 views
0

그냥 내 안드로이드 응용 프로그램에서 내 친구의 페이스 북 벽에 문자 메시지를 게시하고 싶습니다. 여기 내 친구 목록을 나열합니다. &은 내가 보낼 필요가있는 특정 친구 ID가 있습니다.하지만 나는 할 수 없었습니다. 특정 친구에게 메시지를 보낼 수 없습니다. 내 코드는 아래에 있습니다.친구에게 facebook wall 메시지를 게시하십시오

 facebook = new Facebook("My App Id"); 
     asyncRunner = new AsyncFacebookRunner(facebook); 
     FaceBook.facebook.authorize(this, new String[] { "user_status", "user_about_me", "email", "publish_stream", "read_stream", "offline_access" }, new DialogListener() { 

      @Override 
      public void onComplete(Bundle values) { 

       JSONObject jObject; 
       try { 
        jObject = new JSONObject(FaceBook.facebook.request("me")); 
        Bundle params = new Bundle(); 
        params.putString("message", "My message"); 
        params.putString("target_id","My friend fb Id here"); 
        params.putString("method", "stream.publish"); 

        //String response = authenticatedFacebook.request(params); 
        FaceBook.asyncRunner.request("me/feed", params, "POST", 
          new ProductUploadListener(), null); 
        Toast.makeText(getApplicationContext(), "Successfully post..", Toast.LENGTH_SHORT).show(); 

       } catch (MalformedURLException e) { 

        e.printStackTrace(); 
       } catch (JSONException e) { 

        e.printStackTrace(); 
       } catch (IOException e) { 

        e.printStackTrace(); 
       } 
      } 

      @Override 
      public void onFacebookError(FacebookError error) { 
       Toast.makeText(fbFriendsList.this, 
         "Facebook onFacebookError", Toast.LENGTH_LONG).show(); 
      } 

      @Override 
      public void onError(DialogError e) { 
       Toast.makeText(fbFriendsList.this, "Facebook onError", 
         Toast.LENGTH_LONG).show(); 
      } 

      @Override 
      public void onCancel() { 

      } 
     }); 


    } 
    public class ProductUploadListener extends BaseRequestListener { 
     public void onComplete(final String response, final Object state) { 



     } 
    } 

나는 실수를했습니다. 안드로이드 페이스 북 SDK도 사용했습니다.

감사합니다. 여기

+0

http://stackoverflow.com/questions/5280720/facebook-post-on-friends-wall-in-android/7744153#7744153 – Venky

+0

http://stackoverflow.com/question/5217539/help-on-facebook-to-friends-in-android/8577141 # 8577141 – Venky

답변

0

당신이

protected void postOnWall(String friendID) 
{ 
    Bundle params = new Bundle(); 
    params.putString("message","put your message here"); 
    params.putString("caption", "put your caption here"); 
    params.putString("description", "Put your description here"); 
    params.putString("name", "put a name here"); 
    params.putString("picture", "URL of picture"); 
    params.putString("link", "If any link);   

    asyncRunner.request(((friendID == null) ? "me" : userId) + "/feed", params, "POST", new WallPostRequestListener(),null);  
} 
+0

이 샘플을 시도했을 때 asncRunner.request에서 빨간색 줄 오류가 "메서드 요청 (String, Bundle, String, Bundle, String, WallPostRequestListener) " – sanjay

+0

끝 부분에 업데이트 된 답변 puy null이 표시되고 작동하는지 알려주십시오. –

+0

Nope.Not 게시 – sanjay