我在签入后添加了一张照片。我正在使用checkinId添加照片。我收到了来自帖子请求的错误回复。
{"meta":{"code":400,"errorType":"param_error","errorDetail":"Cannot add photo to this checkin (it is a duplicate)"},"response":{}}
String URL_UPLOAD_PHOTO = "https://api.foursquare.com/v2/photos/add";
entity.addPart("v", new StringBody(sdf.format(cal.getTime())));
entity.addPart("checkinId", new StringBody(checkinId));
entity.addPart("public", new StringBody("1"));
entity.addPart("oauth_token", new StringBody(FoursquareConstants.sharedPreference.getToken()));
ByteArrayBody imgBody = new ByteArrayBody(FrameActivity.tempPicByte, "image/jpeg", "happyPhoto");
entity.addPart("image", imgBody);
问题是什么?
答案 0 :(得分:0)
这意味着照片已上传。
答案 1 :(得分:0)
以下代码适用于上传图片。
mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
byte[] bitmapdata = stream.toByteArray();
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://api.foursquare.com/v2/photos/add");
try
{
MultipartEntity entity = new MultipartEntity();
entity.addPart("v", new StringBody("20121210"));
entity.addPart("venueId", new StringBody(venue.getId()));
entity.addPart("public", new StringBody("1"));
entity.addPart("oauth_token", new StringBody(mAccessToken));
ByteArrayBody imgBody = new ByteArrayBody(bitmapdata, "image/jpeg", "FS_image");
entity.addPart("image",imgBody);
httppost.setEntity(entity);
HttpResponse response = httpclient.execute(httppost);
Log.v("response","" +response);
responseResult = inputStreamToString(response.getEntity().getContent()).toString();
}
catch (ClientProtocolException e)
{
Log.d(TAG, "Opening URL " +e);
}