Cla*_*aki 1 post android facebook image
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();
Run Code Online (Sandbox Code Playgroud)
并且正在回归
graphResponse = {响应:responseCode:400,graphObject:null,错误:{HttpStatus:400,errorCode:324,errorType:OAuthException,errorMessage:(#324)需要上传文件}}
请在Json Object param中我需要通过什么?
谢谢
而不是传递json对象,只需传递一个包.
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();
Run Code Online (Sandbox Code Playgroud)