簡體   English   中英

如何在FaceBook牆上張貼消息?

[英]How to post message on FaceBook wall?

我想在Facebook牆上張貼一條消息,我在我的項目中集成了facebook sdk,我的編碼是這樣的,但是在Facebook牆上沒有消息顯示,但是信息來自我的應用程序...這就是我用於發布,

public void updateStatus(String accessToken, String message){  

       System.out.println("mes is "+message);           
       Bundle bundle = new Bundle();     
       bundle.putString("message", message);                    
       facebook.dialog(this, "stream.publish", bundle, this);

}
   public void showPostDailog ( String message ) {
        ProgressDialog authDialog = ProgressDialog.show ( SubmitComplaintActivity.this , "Please wait" ,
              "Posting Message"   , true , // indeterminate
                false ) ;

        Bundle parameters = new Bundle ( ) ;

        parameters.putString ( "link" , reult_complaint_url ) ;
        try {
            String response = mFacebook.request ( "me/feed" , parameters , "POST" ) ;
            System.out.println ( response ) ;
            isCompleteFacbook = true ;
        } catch ( IOException e ) {
            e.printStackTrace ( ) ;
        }
        if ( authDialog != null && authDialog.isShowing ( ) ) {
            authDialog.dismiss ( ) ;
            authDialog.hide ( ) ;
        }
    }

如果使用的是Android Facebook SDK,則代碼位於FacebookConnector.java類中。 postmessageinThread()函數。

if ((fbconnector.getFacebook().isSessionValid())    {
    loginid=FacebookConnector.response;
    System.out.println("FB login ID is"+loginid);
    postMessageInThread(); //Replace this with another activity
    //String url="https://graph.facebook.com/me/friends?access_token=TOKEN";
} else  {
SessionEvents.AuthListener listener = new SessionEvents.AuthListener() {
    public void onAuthSucceed() 
    {
       System.out.println("onAuthSucceed");
       postMessageInThread();
    }
    public void onAuthFail(String error) 
    {
    }
};
SessionEvents.addAuthListener(listener);            System.out.println("Login to Facebook");
        fbconnector.login();

    }
}
private String getFacebookMsg() {
    System.out.println("Login value from getFacenookMSg"+loginid);      
    return "test";
}

我有同樣的問題。 我從搜索中發現以下在facebook.dialog()方法的消息字段的Facebook 文檔中提到的內容:

消息:“此字段將在2011年7月12日被忽略。該消息用於預填充用戶將在其中鍵入的文本字段。為了符合Facebook平台政策,您的應用程序只能在用戶手動生成內容的前提下設置此字段在工作流程中。大多數應用程序不應對此進行設置。”

您需要改用以下內容:

Facebook.request("me/feed", bundle, "POST");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM