Android Flickr rest api(照片上传) HttpClient-HttpClient=newdefaulthttpclient(); HttpPost=新的HttpPost( "http://api.flickr.com/services/upload/"); HttpResponse响应; 试一试{ response=httpclient.execute(post); HttpEntity=response.getEntity(); 如果(实体!=null){ InputStream InputStream=entity.getContent(); BufferedReader BufferedReader=新的BufferedReader( 新的InputStreamReader(inputstream)); StringBuilder StringBuilder=新的StringBuilder(); 字符串currentline=null; 试一试{ 而((currentline=bufferedreader.readLine())!=null){ stringbuilder.append(currentline+“\n”); } }捕获(IOE异常){ e、 printStackTrace(); } 字符串结果=stringbuilder.toString(); 系统输出打印项次(结果); } //HttpPost hp=新的HttpPost(fma.upload\u url); 试一试{ 位图bm=BitmapFactory.decodeFile(file.toString()文件) +“/09102011079.jpg”); ByteArrayOutputStream bas=新的ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG,50,baos); 字节[]b=baos.toByteArray(); ByteArrayBody bab=新的ByteArrayBody(b,“”); MultipartEntity me=新的MultipartEntity(); me.addPart(“媒体”,bab); 邮政实体(me); /*字符串s=“”+“”+“” + "" + "" + "700" + "500" +“适合” + "" + "" + "" + "";*/ /* *请尝试{se=newstringentity;}catch *(不支持编码异常e1){//TODO// *自动生成//捕获//块// *e1.printStackTrace();//}/} */ //BYTEARRAYENTY bae=新BYTEARRAYENTY(b)// //hp.setEntity(se);//hp.setEntity(bae); fma.消费者.标志(张贴); DefaultHttpClient=新的DefaultHttpClient(); 客户。执行(post); }捕获(OAuthMessageSignerException e){ System.out.println(e.getMessage()); }捕获(OAutheExpectationFailedException e){ System.out.println(e.getMessage()); }catch(OAuthCommunicationException e){ System.out.println(e.getMessage()); }catch(ClientProtocolException e){ System.out.println(e.getMessage()); }捕获(IOE){ System.out.println(e.getMessage()); } }捕获(例外e){ }

Android Flickr rest api(照片上传) HttpClient-HttpClient=newdefaulthttpclient(); HttpPost=新的HttpPost( "http://api.flickr.com/services/upload/"); HttpResponse响应; 试一试{ response=httpclient.execute(post); HttpEntity=response.getEntity(); 如果(实体!=null){ InputStream InputStream=entity.getContent(); BufferedReader BufferedReader=新的BufferedReader( 新的InputStreamReader(inputstream)); StringBuilder StringBuilder=新的StringBuilder(); 字符串currentline=null; 试一试{ 而((currentline=bufferedreader.readLine())!=null){ stringbuilder.append(currentline+“\n”); } }捕获(IOE异常){ e、 printStackTrace(); } 字符串结果=stringbuilder.toString(); 系统输出打印项次(结果); } //HttpPost hp=新的HttpPost(fma.upload\u url); 试一试{ 位图bm=BitmapFactory.decodeFile(file.toString()文件) +“/09102011079.jpg”); ByteArrayOutputStream bas=新的ByteArrayOutputStream(); bm.compress(Bitmap.CompressFormat.JPEG,50,baos); 字节[]b=baos.toByteArray(); ByteArrayBody bab=新的ByteArrayBody(b,“”); MultipartEntity me=新的MultipartEntity(); me.addPart(“媒体”,bab); 邮政实体(me); /*字符串s=“”+“”+“” + "" + "" + "700" + "500" +“适合” + "" + "" + "" + "";*/ /* *请尝试{se=newstringentity;}catch *(不支持编码异常e1){//TODO// *自动生成//捕获//块// *e1.printStackTrace();//}/} */ //BYTEARRAYENTY bae=新BYTEARRAYENTY(b)// //hp.setEntity(se);//hp.setEntity(bae); fma.消费者.标志(张贴); DefaultHttpClient=新的DefaultHttpClient(); 客户。执行(post); }捕获(OAuthMessageSignerException e){ System.out.println(e.getMessage()); }捕获(OAutheExpectationFailedException e){ System.out.println(e.getMessage()); }catch(OAuthCommunicationException e){ System.out.println(e.getMessage()); }catch(ClientProtocolException e){ System.out.println(e.getMessage()); }捕获(IOE){ System.out.println(e.getMessage()); } }捕获(例外e){ },android,flickr,photo-upload,Android,Flickr,Photo Upload,这是我的上传代码,但每次我收到这个错误-------> 11-14 12:20:33.515:信息/系统输出(444): err code=“100”msg=“API密钥无效(密钥格式无效)” 请帮帮我。提前谢谢。如果您看一下 100:无效的API密钥: 传递的API密钥无效或已过期 所以我猜你的API密钥是不正确的。要使用Flickr API,您需要有一个应用程序密钥 目前,只有在事先获得许可的情况下,才允许将API用于商业用途。用于商业用途的API密钥请求由工作人员审查 这是 未指定照片

这是我的上传代码,但每次我收到这个错误------->

11-14 12:20:33.515:信息/系统输出(444):
err code=“100”msg=“API密钥无效(密钥格式无效)”


请帮帮我。提前谢谢。

如果您看一下

100:无效的API密钥: 传递的API密钥无效或已过期

所以我猜你的API密钥是不正确的。要使用Flickr API,您需要有一个应用程序密钥

目前,只有在事先获得许可的情况下,才允许将API用于商业用途。用于商业用途的API密钥请求由工作人员审查

这是


未指定照片
缺少photo required参数。

如果查看

100:无效的API密钥: 传递的API密钥无效或已过期

所以我猜你的API密钥是不正确的。要使用Flickr API,您需要有一个应用程序密钥

目前,只有在事先获得许可的情况下,才允许将API用于商业用途。用于商业用途的API密钥请求由工作人员审查

这是


未指定照片
缺少photo required参数。

我现在更正了代码,它有另一个错误代码,名为“错误代码2无照片”specified@Reno链接已断开。我更正了我的代码,现在它有另一个名为错误代码2无照片specified@Reno林克死了。
HttpClient httpclient = new DefaultHttpClient();
            HttpPost post = new HttpPost(
                    "http://api.flickr.com/services/upload/");
            HttpResponse response;
            try {
                response = httpclient.execute(post);
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    InputStream inputstream = entity.getContent();
                    BufferedReader bufferedreader = new BufferedReader(
                            new InputStreamReader(inputstream));
                    StringBuilder stringbuilder = new StringBuilder();
                    String currentline = null;
                    try {
                        while ((currentline = bufferedreader.readLine()) != null) {
                            stringbuilder.append(currentline + "\n");
                        }
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    String result = stringbuilder.toString();
                    System.out.println(result);
                }

                // HttpPost hp = new HttpPost(fma.upload_url);
                try {
                    Bitmap bm = BitmapFactory.decodeFile(file.toString()
                            + "/09102011079.jpg");
                    ByteArrayOutputStream baos = new ByteArrayOutputStream();
                    bm.compress(Bitmap.CompressFormat.JPEG, 50, baos);
                    byte[] b = baos.toByteArray();
                    ByteArrayBody bab = new ByteArrayBody(b, "");
                    MultipartEntity me = new MultipartEntity();
                    me.addPart("media", bab);
                    post.setEntity(me);
                    /*String s = "<root>" + "<entities>" + "<media>"
                            + "<size>" + "<large>" + "<width>700</width>"
                            + "<height>500<height>"
                            + "<resize>\"fit\"</resize>" + "</large>"
                            + "</size>" + "</media>" + "</entities>"
                            + "</root>";*/
                    /*
                     * try { se = new StringEntity(s); } catch
                     * (UnsupportedEncodingException e1) { // TODO //
                     * Auto-generated // catch // block //
                     * e1.printStackTrace(); // } // }
                     */
                    // ByteArrayEntity bae = new ByteArrayEntity(b); //
                    // hp.setEntity(se); // hp.setEntity(bae);
                    fma.consumer.sign(post);
                    DefaultHttpClient client = new DefaultHttpClient();
                    client.execute(post);
                } catch (OAuthMessageSignerException e) { 
                    System.out.println(e.getMessage());
                } catch (OAuthExpectationFailedException e) { 
                    System.out.println(e.getMessage());
                } catch (OAuthCommunicationException e) { 
                    System.out.println(e.getMessage());
                } catch (ClientProtocolException e) { 
                    System.out.println(e.getMessage());
                } catch (IOException e) { 
                    System.out.println(e.getMessage());
                }

            } catch (Exception e) {

            }