gpt4 book ai didi

java - 在 facebook 墙上发布 sdk 3.5 android 错误

转载 作者:行者123 更新时间:2023-12-01 13:40:04 26 4
gpt4 key购买 nike

我已经完成 Facebook 集成登录,登录后我想在墙上发布一些消息,但我没有成功,因为我收到此错误

 **{Response:  responseCode: 200, graphObject: null, error: {HttpStatus: 200, errorCode: 3, errorType: null, errorMessage: Unknown method}, isFromCache:false}**  

我的代码如下

postbtn.setOnClickListener(new OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try {



final Bundle params = new Bundle();

params.putString("message", "Test");
//params.putString("name", "American Virgin");
//params.putString("link", "http://bit.ly/12345");
//params.putString("description", "A Freshman College Girl on a scholarship from an ...");
//http://graph.facebook.com/100000431012652/picture?type=square
final Request postToWall = Request.newRestRequest(Session.getActiveSession(), "me/feed", params, HttpMethod.POST);
postToWall.setCallback( new Request.Callback()
{

@Override
public void onCompleted(Response response)
{
Log.i("onCompleted", response.toString());

}
});
Request.executeBatchAsync(postToWall);










} catch (Exception e) {
// TODO Auto-generated catch block
Log.i("onCompletedException", e.toString());
}


}
});


}

请推荐我。对于登录,我使用下面的代码

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

// callback when session changes state
@SuppressWarnings("deprecation")

@Override
public void call(final Session session, SessionState state, Exception exception) {


if (session.isOpened()) {
// Log.i("session.isOpened", "session.isOpened");
//session.requestNewReadPermissions(newPermissionsRequest);

// make request to the /me API
Request.executeMeRequestAsync(session, new Request.GraphUserCallback() {

// callback after Graph API response with user object
@Override
public void onCompleted(GraphUser user, Response response) {

//session.requestNewReadPermissions(newPermissionsRequest);

//System.out.println("Response : "+response.toString());
Log.i("Response", response.toString());

//URL image_value = new URL("http://graph.facebook.com/"+id+"/picture?style=small" );


if (user != null) {

Log.i("USERName", ""+user.getName());
Log.i("Birthday", ""+user.getBirthday());
Log.i("LastName", ""+user.getLastName());
Log.i("FirstName", ""+user.getFirstName());
Log.i("getId", ""+user.getId());
Log.i("email", " "+user.getLink()+" email : ) "+user.asMap().get("email"));
Log.i("location", ""+user.asMap().get("location"));
Log.i("gender", ""+user.asMap().get("gender"));

saveusrname = ""+user.getName().trim();


imagstring = "http://graph.facebook.com/"+""+""+user.getId()+"/picture?type=square";

// imagstring = "http://graph.facebook.com/"+""+""+user.getId()+"/picture?type=large";
//type=square
Log.i("imagstring", imagstring);

finish();


/* String username = ""+user.getName();
String Birthday = ""+user.getBirthday();
String email = ""+user.asMap().get("email");
String location = ""+user.asMap().get("location");
String gender = ""+user.asMap().get("gender");*/


new SendfacebookValue().execute(response.toString(),saveusrname.toString(),imagstring);


/*Intent i =new Intent(FacebookLogin.this, ScreenNameActivity.class);
startActivity(i);*/

/* Intent i =new Intent(getApplicationContext(), MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(i);*/

//finish();

}
}
});



}
}
});

最佳答案

我使用这种方法在 Facebook 墙上发布记录。我认为这会对您有所帮助,请检查您的 GraphObject

  private void postStatusUpdate() {
Log.d("myLogs", "Test");
Session session = Session.getActiveSession();
if (!session.isOpened() && !session.isClosed()) {
session.openForRead(new Session.OpenRequest(this).setCallback(statusCallback));
} else {
Session.openActiveSession(this, true, statusCallback);
Log.d("myLogs", "Test 1");
final String message = "massage to post";
Request request = Request
.newStatusUpdateRequest(Session.getActiveSession(), message, new Request.Callback() {
@Override
public void onCompleted(Response response) {
showPublishResult(message, response.getGraphObject(), response.getError());
}
});
request.executeAsync();
}
}


private void showPublishResult(String message, GraphObject result, FacebookRequestError error) {
String title = null;
String alertMessage = null;
if (error == null) {
title = "Success";

alertMessage = "All is good";
} else {
title = "Error";
alertMessage = error.getErrorMessage();
}

new AlertDialog.Builder(this)
.setTitle(title)
.setMessage(alertMessage)
.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.show();
}

关于java - 在 facebook 墙上发布 sdk 3.5 android 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20900882/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com