我正在使用Android Facebook SDK 3.8。我正试图在朋友的墙上贴一个文字。即使没有错误(我得到了post-id),我也看不到帖子在我朋友的墙上。我试过WebDialog,facebook.dialog,但没有运气。当我在墙上张贴东西时,一切正常。
这是代码。
btnPostToWall.setOnClickListener(new View.OnClickListener() {
@SuppressLint("SimpleDateFormat")
@SuppressWarnings("deprecation")
@Override
public void onClick(View v) {
try{
mSession.requestNewPublishPermissions(new Session.NewPermissionsRequest(mActivity, "publish_actions", "publish_stream"));
String fqlQuery = "SELECT uid,first_name,last_name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) ORDER BY last_name ASC";
Bundle params = new Bundle();
params.putString("format", "json");
params.putString("q", fqlQuery);
params.putString("access_token", mSession.getAccessToken());
Request request = new Request(mSession, "/fql",
params, HttpMethod.GET,
new Request.Callback() {
public void onCompleted(
Response response) {
GraphObject go = response.getGraphObject();
JSONObject jso = go.getInnerJSONObject();
try {
JSONArray arr = jso.getJSONArray("data");
for ( int i = 0; i < ( arr.length() ); i++ )
{
JSONObject json_obj = arr.getJSONObject( i );
String name = json_obj.getString("first_name");
if(name.contains("Shivanka")){
String uid = json_obj.getString("uid");
Facebook facebook=new Facebook("************");
Bundle parameters = new Bundle();
parameters.putString("to", uid);
facebook.dialog(mActivity,"feed",parameters,new DialogListener() {
@Override
public void onComplete(Bundle values) {
final String postId = values.getString("post_id");
if (postId != null) {
Toast.makeText(mActivity,
"Posted story, id: "+postId,
Toast.LENGTH_SHORT).show();
} else {
// User clicked the Cancel button
Toast.makeText(mActivity.getApplicationContext(),
"Publish cancelled",
Toast.LENGTH_SHORT).show();
}
}
@Override
public void onCancel() {
//Display your message on dialog cancel
}
@Override
public void onFacebookError(
FacebookError e) {
Toast.makeText(mActivity.getApplicationContext(),
e.getMessage(),
Toast.LENGTH_SHORT).show();
}
@Override
public void onError(
DialogError e) {
Toast.makeText(mActivity.getApplicationContext(),
e.getMessage(),
Toast.LENGTH_SHORT).show();
}
});
}
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});
Request.executeBatchAsync(request);
}catch(Exception e){
Toast.makeText(mActivity,
"Eexception : " + e.getLocalizedMessage(),
Toast.LENGTH_SHORT).show();
}
}
});
答案 0 :(得分:1)
您的应用程序必须仍然处于开发 模式,这就是该帖子对其他用户不可见的原因,因为他们不是该应用的开发者/管理员/测试人员
您可以在应用设置中将应用模式更改为直播 -