Android Facebook v4.0发布图像和文本
现在又回来了 graphResponse={Response:responseCode:400,graphObject:null,错误:{HttpStatus:400,错误代码:324,错误类型:OAutheException,错误消息:324需要上传文件}} 请输入Json对象参数,我需要传递什么Android Facebook v4.0发布图像和文本,android,facebook,image,post,Android,Facebook,Image,Post,现在又回来了 graphResponse={Response:responseCode:400,graphObject:null,错误:{HttpStatus:400,错误代码:324,错误类型:OAutheException,错误消息:324需要上传文件}} 请输入Json对象参数,我需要传递什么 谢谢newPostRequest用于创建图形对象,而不是照片。使用SDK的v4.0,您应该创建一个ShareContent,然后使用ShareApi共享它,类似于: JSONObject json
谢谢newPostRequest用于创建图形对象,而不是照片。使用SDK的v4.0,您应该创建一个ShareContent,然后使用ShareApi共享它,类似于:
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("picture", bitmap);
jsonObject.put("message","just a message");
} catch (JSONException e) {
e.printStackTrace();
}
GraphRequest graphRequest = GraphRequest.newPostRequest(AccessToken.getCurrentAccessToken(), "me/photos", jsonObject, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
Log.d("", "------ graphResponse = " + graphResponse);
}
});
graphRequest.executeAsync();
有关更多信息,请参阅。newPostRequest用于创建图形对象,而不用于照片。使用SDK的v4.0,您应该创建一个ShareContent,然后使用ShareApi共享它,类似于:
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("picture", bitmap);
jsonObject.put("message","just a message");
} catch (JSONException e) {
e.printStackTrace();
}
GraphRequest graphRequest = GraphRequest.newPostRequest(AccessToken.getCurrentAccessToken(), "me/photos", jsonObject, new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse graphResponse) {
Log.d("", "------ graphResponse = " + graphResponse);
}
});
graphRequest.executeAsync();
有关更多信息,请参阅。只传递bundle-one,而不是传递json对象
Bitmap image = ...
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image);
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareApi.share(content, new FacebookCallback<Sharer.Result>() { ...});
不传递json对象,只传递bundle-one
Bitmap image = ...
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image);
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareApi.share(content, new FacebookCallback<Sharer.Result>() { ...});
公开作废postToFacebook{
GraphRequest request = GraphRequest.newPostRequest(token,
"me/photos", null, callback2);
Bundle postParams = request.getParameters();
postParams.putByteArray("picture", MyUtils.FileToBytes("path to local file"));
postParams.putString("caption", "my picture");
request.setParameters(postParams);
request.executeAsync();
公开作废postToFacebook{
GraphRequest request = GraphRequest.newPostRequest(token,
"me/photos", null, callback2);
Bundle postParams = request.getParameters();
postParams.putByteArray("picture", MyUtils.FileToBytes("path to local file"));
postParams.putString("caption", "my picture");
request.setParameters(postParams);
request.executeAsync();
此外,没有添加消息的机制。在iOS中,可以自动发布图像和消息NSMutableDictionary*dictionary=[NSMutableDictionary];[dictionary setObject:UIImagePNGRepresentationimage forKey:@picture];[dictionary setObject:@test forKey:@message];FBSDKGraphRequest*连接=[[FBSDKGraphRequest alloc]initWithGraphPath:@me/photos参数:dictionary HTTPMethod:@POST];[connection startWithCompletionHandler:^FBSDKGraphRequestConnection连接,id结果,N错误{}];没错,如果您使用的是Graph API,这可能是Android SDK方面的疏忽。此外,没有添加消息的机制。在iOS中,可以自动发布图像和消息NSMutableDictionary*dictionary=[NSMutableDictionary];[dictionary setObject:UIImagePNgPresentationImage forKey:@picture];[dictionary setObject:@test forKey:@message];FBSDKGraphRequest*连接=[[FBSDKGraphRequest alloc]initWithGraphPath:@me/photos参数:dictionary HTTPMethod:@POST];[connection startWithCompletionHandler:^FBSDKGraphRequestConnection连接,id结果,N错误错误{}];没错,如果您使用的是Graph API,这可能是Android SDK方面的疏忽。