0

I am adding a photo after checkin. I am using that checkinId to add photo. I am getting error response from post request.

{"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);

What's the problem?

4

2 回答 2

0

这意味着照片已经上传。

于 2013-01-30T17:10:47.663 回答
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);
} 
于 2014-04-03T19:30:04.890 回答