我使用以下代码上传视频
Request.Callback callback5 = new Request.Callback() {
public void onCompleted(Response response) {
// response will have an id if successful
Log.e("HackBook", "Response = "+response);
}
};
File tempFile;
try {
tempFile = createTempFileFromAsset(getApplicationContext(), "video.mp4");
Request request5 = Request.newUploadVideoRequest(Session.getActiveSession(),
tempFile, callback5);
RequestAsyncTask task5 = new RequestAsyncTask(request5);
task5.execute();
} catch (IOException e) {
Log.e("HackBook", "failed to create temp file");
e.printStackTrace();
}
public static File createTempFileFromAsset(Context context, String assetPath)
throws IOException {
InputStream inputStream = null;
FileOutputStream outStream = null;
try {
AssetManager assets = context.getResources().getAssets();
inputStream = assets.open(assetPath);
File outputDir = context.getCacheDir(); // context being the
// Activity pointer
File outputFile = File.createTempFile("prefix", assetPath,
outputDir);
outStream = new FileOutputStream(outputFile);
final int bufferSize = 1024 * 2;
byte[] buffer = new byte[bufferSize];
int n = 0;
while ((n = inputStream.read(buffer)) != -1) {
outStream.write(buffer, 0, n);
}
return outputFile;
} finally {
com.facebook.internal.Utility.closeQuietly(outStream);
com.facebook.internal.Utility.closeQuietly(inputStream);
}
}
它返回以下错误消息
{Response: responseCode: 400, graphObject: null, error: {HttpStatus:
400, errorCode: 2500, errorType: OAuthException, errorMessage: An
active access token must be used to query information about the
current user.}, isFromCache:false}
你能指导我哪里出错了吗?