我正在使用Theta Camera SDK以360度拍摄照片。
我想将此照片发布到Facebook这是360张照片。
String path= "/storage/emulated/0/path/imagebitmap.jpg";
SharePhoto photo = new SharePhoto.Builder()
.setImageUrl(Uri.fromFile(new File(path)))
.setCaption("")
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
ShareApi.share(content,shareCallback);
它成功发布在Facebook上,但看起来像那样
我正在使用._er_injected更改扩展名,但会出现同样的问题。
同样使用此代码
Bitmap icon = BitmapFactory.decodeResource(getResources(),R.drawable.imagebitmap);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
Bundle params = new Bundle();
/*spherical_metadata*/
String mjson="{\"ProjectionType\": \"equirectangular\",\"CroppedAreaImageWidthPixels\": 240,\"CroppedAreaImageHeightPixels\": 240,\"FullPanoWidthPixels\": 1962,\"FullPanoHeightPixels\": 981,\"CroppedAreaLeftPixels\": 981,\"CroppedAreaTopPixels\": 490}";
params.putByteArray("picture", byteArray);
params.putBoolean("allow_spherical_photo", true);
params.putString("spherical_metadata", mjson);
params.putString("name", "Panorama images");
/* make the API call */
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/photos",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
Log.e("@@@response", String.valueOf(response));
// Toast.makeText()
}
}
).executeAsync();
我认为我是以错误的方式调用API。
答案 0 :(得分:0)
最后通过Read this Link获得了解决方案,并通过Facebook调用图表Api
了解这个球形仔细阅读来自两个链接的ProjectionType,CroppedAreaImageWidthPixels等所做的更改。
拍摄的尺寸是相同尺寸的图像(5376 * 2688)所以根据图像宽度高度拍摄尺寸
private void sharePhotoToFacebook(){
Bitmap icon = BitmapFactory.decodeResource(getResources(),R.drawable.imagebitmap);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
Bundle params = new Bundle();
JSONObject json= new JSONObject();
try {
json.put("ProjectionType", "equirectangular");
json.put("CroppedAreaImageWidthPixels", 5376);
json.put("CroppedAreaImageHeightPixels", 2688);
json.put("FullPanoWidthPixels", 5376);
json.put("FullPanoHeightPixels", 2688);
json.put("CroppedAreaLeftPixels", 0);
json.put("CroppedAreaTopPixels", 0);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JSONObject jsonObject=new JSONObject();
params.putByteArray("picture", byteArray);
params.putBoolean("allow_spherical_photo", true);
params.putString("spherical_metadata", json.toString());
new GraphRequest(
AccessToken.getCurrentAccessToken(),
"/me/photos",
params,
HttpMethod.POST,
new GraphRequest.Callback() {
public void onCompleted(GraphResponse response) {
/* handle the result */
Log.e("@@@response", String.valueOf(response));
Toast.makeText(getApplicationContext(),"Snapshot shared On Facebook",Toast.LENGTH_SHORT).show();
}
}
).executeAsync();
}