将视频上传到twitvid

时间:2012-06-07 06:55:51

标签: android

现在,我正在做的功能:通过twitvid将视频上传到Twitter。我使用以下代码上传视频,但这是错误的:

  TwitterSession twitterSession = new TwitterSession(SendImageActivity.this);            
    AccessToken accessToken     = twitterSession.getAccessToken();

        Values values = new Values();
        values.setSession(new Session());
        api = new TwitvidApi(values);
                api.setSecureUrlEnabled(false);                                         

                Session session;
                session = api.authenticate(new TwitterAuthPack.Builder()
                .setConsumerKey(twitter_consumer_key)
                .setConsumerSecret(twitter_secret_key)
                .setOAuthToken(accessToken.getToken())
                .setOAuthTokenSecret(accessToken.getTokenSecret())
                .build());

        api.getValues().setSession(session);

                final UploadHelper helper = new UploadHelper(api);

                File file=new File("/mnt/sdcard/video1.flv");
                TwitvidPost twitvidPost = new TwitvidPost.Builder()
                        .setFile(file).setChunkSize(10485760)  /*10MB chunk size*/
                        .setMessage("Twitviding from Java").setPostToTwitter(true).setListener(new uploadListener())
                        .create();
                try {
                    if (helper.upload(twitvidPost)) 
                    {
                        result=1;
                                        Toast.makeText(getBaseText(),"Success",Toast.LENGH_SHORT).show();  
                    } 
                    else 
                    {
                    result=2;
                  Toast.makeText(getBaseText(),"Unsuccess",Toast.LENGH_SHORT).show();
                    }
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            } catch (ApiException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

记录猫如下: http://nn4.upanh.com/b6.s29.d1/4493c1f16e59e9f76cc29754cd2f534a_45818734.untitled.png

你能帮助我吗?

1 个答案:

答案 0 :(得分:0)

我使用相同的代码将视频上传到twitvid但不上传到twitter。您最好使用这些jar文件twitter4j-core-2.2.6twitvidsdk.jar。它会起作用。