是否可以使用GraphApi替换现有的FB照片?我使用以下代码段尝试替换照片:
GraphRequest fbUpload = new GraphRequest();
Bundle fbUploadParams = new Bundle();
fbUploadParams.putByteArray("source", imageData);
fbUpload.setAccessToken(AccessToken.getCurrentAccessToken());
fbUpload.setHttpMethod(HttpMethod.POST);
if (photoUploadRecord.photoId != null) {
fbUpload.setGraphPath(photoUploadRecord.photoId);
} else {
fbUpload.setGraphPath(photoUploadRecord.albumId + "/" + FloomitFb.FB_PHOTO_EDGE);
}
fbUpload.setParameters(fbUploadParams);
GraphResponse response = fbUpload.executeAndWait();
FacebookRequestError requestError = response.getError();
未返回任何错误,但照片未更新。代码查看photoId,如果不为null,则将其用作GraphPath,这是用于更新照片的GraphApi文档中描述的内容,但不清楚照片更新是否只是指更新与之相关的各个字段照片(评论/标签/喜欢/等......)或图片本身。此代码成功上传了一张新照片(例如photoId == null)。