繁体   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