从自己的android应用程序将图像共享到inastagram

从自己的android应用程序将图像共享到inastagram,android,instagram,Android,Instagram,我正在尝试将我的android应用程序中的图像共享到instagram应用程序中。。。。。。。。。我无法上传图像 @SuppressWarnings("unchecked") public Map<String, String> doUpload() { Log.i(TAG, "Upload"); Long timeInMilliseconds = System.currentTimeMillis()/1000; String timeInSeconds = timeInMillis

我正在尝试将我的android应用程序中的图像共享到instagram应用程序中。。。。。。。。。我无法上传图像

@SuppressWarnings("unchecked")
public Map<String, String> doUpload() {
Log.i(TAG, "Upload");
Long timeInMilliseconds = System.currentTimeMillis()/1000;
String timeInSeconds = timeInMilliseconds.toString();
MultipartEntity multipartEntity = new     
MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
Map returnMap = new HashMap<String, String>();
// check for cookies
/*  if( httpClient.getCookieStore() == null ) {
 returnMap.put("result", "Not logged in");
        return returnMap;
    }*/

    try {
        // create multipart data
         System.out.println("image path name : "+processedImageUri.getPath());
         System.out.println("image file path : "+ImgFilePath);
        File imageFile = new File(ImgFilePath);//processedImageUri.getPath());
        FileBody partFile = new FileBody(imageFile);
        StringBody partTime = new StringBody(timeInSeconds);

        multipartEntity.addPart("photo", partFile );
        multipartEntity.addPart("device_timestamp", partTime);
    } catch ( Exception e ) {
        Log.e(TAG,"Error creating mulitpart form: " + e.toString());
        returnMap.put("result", "Error creating mulitpart form: " + e.toString());
        return returnMap;
    }

    // upload
    try {
        System.out.println("111111111111111111");
        System.out.println("multipart entity value : "+multipartEntity.toString());
        HttpPost httpPost = new HttpPost(Utils.UPLOAD_URL);
        httpPost.setEntity(multipartEntity);
        System.out.println("http post vlaue : "+httpPost.toString());
        System.out.println("http client value : "+httpClient.toString());
        HttpResponse httpResponse = httpClient.execute(httpPost);
        System.out.println("Http response value : "+httpResponse.toString());
        HttpEntity httpEntity = httpResponse.getEntity();
        Log.i(TAG, "Upload status: " + httpResponse.getStatusLine());
        System.out.println("staus entity value : "+httpResponse.getStatusLine().toString());
        System.out.println("http status : "+HttpStatus.SC_OK);

        // test result code
        if( httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK ) {
            Log.e(TAG, "Login HTTP status fail: " + httpResponse.getStatusLine().getStatusCode());
            returnMap.put("result", "HTTP status error: " + httpResponse.getStatusLine().getStatusCode() );
            return returnMap;
        }

        // test json response
        // should look like
        /*
        {"status": "ok"}
        */
        if( httpEntity != null ) {
            BufferedReader reader = new BufferedReader(new InputStreamReader(httpEntity.getContent(), "UTF-8"));
            String json = reader.readLine();
            System.out.println("Entity value : "+json);
            JSONTokener jsonTokener = new JSONTokener(json);
            JSONObject jsonObject = new JSONObject(jsonTokener);
            Log.i(TAG,"JSON: " + jsonObject.toString());

            String loginStatus = jsonObject.getString("status");

            if( !loginStatus.equals("ok") ) {
                Log.e(TAG, "JSON status not ok: " + jsonObject.getString("status"));
                returnMap.put("result", "JSON status not ok: " + jsonObject.getString("status") );
                return returnMap;
            }
        }
    } catch( Exception e ) {
        Log.e(TAG, "HttpPost exception: " + e.toString());
        returnMap.put("result", "HttpPost exception: " + e.toString());
        return returnMap;
    }

    // configure / comment
    try {
        HttpPost httpPost = new HttpPost(Utils.CONFIGURE_URL);
        String partComment = txtCaption.getText().toString();
        List<NameValuePair> postParams = new ArrayList<NameValuePair>();
        postParams.add(new BasicNameValuePair("device_timestamp", timeInSeconds));
        postParams.add(new BasicNameValuePair("caption", partComment));
        httpPost.setEntity(new UrlEncodedFormEntity(postParams, HTTP.UTF_8));
        System.out.println("http client value : "+httpClient.toString());
        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();

        // test result code
        if( httpResponse.getStatusLine().getStatusCode() != HttpStatus.SC_OK ) {
            Log.e(TAG, "Upload comment fail: " + httpResponse.getStatusLine().getStatusCode());
            returnMap.put("result", "Upload comment fail: " + httpResponse.getStatusLine().getStatusCode() );
            return returnMap;
        }

        returnMap.put("result", "ok");
        return returnMap;
    } catch( Exception e ) {
        Log.e(TAG, "HttpPost comment error: " + e.toString());
        returnMap.put("result", "HttpPost comment error: " + e.toString());
        return returnMap;
    }
@SuppressWarnings(“未选中”)
公共地图双pload(){
Log.i(标签“上传”);
Long-timeinmillises=System.currentTimeMillis()/1000;
字符串timeinsectonds=timeinmillizes.toString();
MultipartEntity MultipartEntity=新
多端口(HttpMultipartMode.BROWSER_兼容);
Map returnMap=newhashmap();
//检查是否有饼干
/*if(httpClient.getCookieStore()==null){
returnMap.put(“结果”,“未登录”);
返回地图;
}*/
试一试{
//创建多部分数据
System.out.println(“图像路径名:+processedImageUri.getPath());
System.out.println(“图像文件路径:+ImgFilePath”);
File imageFile=新文件(ImgFilePath);//processedimageri.getPath();
FileBody partFile=新的FileBody(imageFile);
StringBody partTime=新的StringBody(timeInSeconds);
addPart(“照片”,partFile);
multipatentity.addPart(“设备\时间戳”,partTime);
}捕获(例外e){
Log.e(标记,“创建多部分表单时出错:”+e.toString());
returnMap.put(“结果”,“创建多部分表单时出错:”+e.toString());
返回地图;
}
//上传
试一试{
System.out.println(“111111111111”);
System.out.println(“多部分实体值:“+multipartEntity.toString());
HttpPost HttpPost=新的HttpPost(Utils.UPLOAD\uURL);
httpPost.setEntity(多协议实体);
System.out.println(“http-post-vlue:+httpPost.toString());
System.out.println(“http客户端值:+httpClient.toString());
HttpResponse HttpResponse=httpClient.execute(httpPost);
System.out.println(“Http响应值:+httpResponse.toString());
HttpEntity HttpEntity=httpResponse.getEntity();
Log.i(标记“上载状态:”+httpResponse.getStatusLine());
System.out.println(“staus实体值:+httpResponse.getStatusLine().toString());
System.out.println(“http状态:+HttpStatus.SC_OK”);
//测试结果代码
如果(httpResponse.getStatusLine().getStatusCode()!=HttpStatus.SC_OK){
Log.e(标记“登录HTTP状态失败:”+httpResponse.getStatusLine().getStatusCode());
returnMap.put(“结果”,“HTTP状态错误:+httpResponse.getStatusLine().getStatusCode());
返回地图;
}
//测试json响应
//应该像
/*
{“状态”:“确定”}
*/
if(httpEntity!=null){
BufferedReader=新的BufferedReader(新的InputStreamReader(httpEntity.getContent(),“UTF-8”);
字符串json=reader.readLine();
System.out.println(“实体值:”+json);
JSONTokener JSONTokener=新的JSONTokener(json);
JSONObject JSONObject=新的JSONObject(jsonTokener);
i(标记“JSON:+jsonObject.toString());
stringloginstatus=jsonObject.getString(“状态”);
如果(!loginStatus.equals(“ok”)){
Log.e(标记“JSON状态不正常:”+jsonObject.getString(“状态”));
returnMap.put(“结果”,“JSON状态不正常:”+jsonObject.getString(“状态”));
返回地图;
}
}
}捕获(例外e){
Log.e(标记为“HttpPost异常:+e.toString());
returnMap.put(“result”,“HttpPost异常:”+e.toString());
返回地图;
}
//配置/注释
试一试{
HttpPost HttpPost=新的HttpPost(Utils.CONFIGURE\uURL);
String partComment=txtCaption.getText().toString();
List postParams=new ArrayList();
添加(新的BasicNameValuePair(“设备_时间戳”,timeUnseconds));
添加(新的BasicNameValuePair(“标题”,partComment));
setEntity(新的UrlEncodedFormEntity(postParams,HTTP.UTF_8));
System.out.println(“http客户端值:+httpClient.toString());
HttpResponse HttpResponse=httpClient.execute(httpPost);
HttpEntity HttpEntity=httpResponse.getEntity();
//测试结果代码
如果(httpResponse.getStatusLine().getStatusCode()!=HttpStatus.SC_OK){
Log.e(标记“上传注释失败:”+httpResponse.getStatusLine().getStatusCode());
returnMap.put(“结果”,“上传注释失败:+httpResponse.getStatusLine().getStatusCode());
返回地图;
}
returnMap.put(“结果”、“确定”);
返回地图;
}捕获(例外e){
Log.e(标记“HttpPost注释错误:”+e.toString());
returnMap.put(“结果”,“HttpPost注释错误:+e.toString());
返回地图;
}
上面是我用来上传图片的代码,它的url是upload_url=”http://instagr.am/api/v1/media/upload/" .............
请任何人帮我将图片上传到instagram……。提前谢谢。

instagram API还不支持上传

从Instagram API文档:

目前无法通过API上传。出于以下原因,我们有意识地选择不添加此内容:

Instagram讲述的是你的忙碌生活——我们希望鼓励你拍摄照片 从应用程序内部。但是,将来我们可能会给出白名单 在个案基础上访问单个应用程序。我们想要战斗 垃圾邮件和低质量照片。一旦我们允许从其他来源上传, 很难控制进入Instagram生态系统的内容 话虽如此,我们仍在努力确保用户拥有 在我们的平台上提供始终如一的高质量体验


Instagram API还不支持上传

从Instagram API文档:

此时,正在上载v