2013-11-28 27 views
0

我想在Facebook上发布消息,而无需使用原生Facebook Android应用程序打开对话框。 我正在使用Facebook SDK 3.5.2。 我已成功在墙上发布消息。如何在Facebook上发布消息而不打开任何对话框?

我正面临一些问题。

1)如果我从原生Facebook应用程序注销。然后它将消息发送到之前用户的Facebook墙&它不要求认证。 2)如果用户在Facebook本地应用程序中使用不同的帐户登录,它仍然会将消息发布到 上一个帐户(通过应用程序首次登录)。不要求认证。

代码: -

Session.openActiveSession(this, true, new Session.StatusCallback() { 

       // callback when session changes state 
       @Override 
       public void call(Session session, SessionState state, Exception exception) { 
        if (session.isOpened()) { 

         new messagePostAsyn().execute(session); 

        } 
       } 
       }); 

方法:

private void postStatus(final Session session, String message) { 


    Bundle _postParameter = new Bundle(); 
    _postParameter.putString("name", message); 

    _postParameter.putByteArray("picture", bytes); 
    _postParameter.putString("caption", "To help...."); 
    _postParameter.putString("description", "Testing..."); 
    Request request = new Request(session, "me/photos", _postParameter, 
      HttpMethod.POST, new Callback() { 

       @Override 
       public void onCompleted(Response response) { 
        // TODO Auto-generated method stub 
        System.out.println("response......" + response); 

       } 
      }); 



    Request.executeBatchAsync(request); 


} 

在messagePostAsyn()类使用此方法。

回答

0

试试这个代码:

public void postToWall(String message) { 
    Bundle params = new Bundle(); 
    params.putString("message", message); 

    // Uses the Facebook Graph API 
    try { 
     facebook.request("/me/feed", params, "POST"); 
     this.finish(); 
    } catch (FileNotFoundException e) { 
     e.printStackTrace(); 
    } catch (MalformedURLException e) { 
     e.printStackTrace(); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
} 
+0

为什么从本机应用程序注销后发布消息。在此,我们需要发布的消息后清除令牌? – mukesh

+0

有什么方法可以知道用户是否从原生Facebook应用程序注销,然后我的应用程序要求登录,否则不要求登录? – mukesh

+0

请不要再使用Facebook类,整个班级已被弃用,不会被支持。没有办法知道用户是否从原生Facebook应用程序注销。 –

相关问题