无法使用Android在Twitter上发布视频

时间:2013-07-26 20:34:50

标签: android twitter

我想在我的Android手机上发布一个视频,但我得到了错误,不知道如何解决这个错误我真的需要你的帮助,因为我是android开发的新手......

这是我使用android os上传视频的代码: -

btnuploadvideo.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View arg0) {

                    Uri video = Uri.parse("android.resource://" + getPackageName() + "/"
                            + R.raw.test);
                    postToTwitvid(video.getPath());

                }
            });



private void postToTwitvid(String videoPath){

        String access_token = mSharedPreferences.getString(PREF_KEY_OAUTH_TOKEN, "");
        // Access Token Secret
        String access_token_secret = mSharedPreferences.getString(PREF_KEY_OAUTH_SECRET, "");
        AccessToken token = new AccessToken(access_token, access_token_secret);

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

                Session session;
                try {
                    session = api.authenticate(new TwitterAuthPack.Builder()
                    .setConsumerKey(TWITTER_CONSUMER_KEY)
                    .setConsumerSecret(TWITTER_CONSUMER_SECRET)
                    .setOAuthToken(token.getToken())
                    .setOAuthTokenSecret(token.getTokenSecret())
                    .build());

                    api.getValues().setSession(session);

                    final UploadHelper helper = new UploadHelper(api);

                    File file=new File(videoPath);
                    TwitvidPost twitvidPost = new TwitvidPost.Builder()
                            .setFile(file).setChunkSize(10485760)
                            .setMessage("Twitvid test")
                            .setPostToTwitter(true)
                            .create();
                    try {
                        if (helper.upload(twitvidPost))
                        {
                            Toast.makeText(MainActivity.this, "Posted on Twitter and Twitvid", Toast.LENGTH_LONG).show();
                        } 
                        else 
                        {
                            Toast.makeText(MainActivity.this, "Post failed", Toast.LENGTH_LONG).show();
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                } catch (ApiException e1) {
                    e1.printStackTrace();
                }
}

日志猫是: -

07-26 20:18:06.549: W/System.err(639): Exception[java.lang.RuntimeException: A Twitvid API error occurred, ErrorResponse{code=1001, message='Couldn't authenticate via Telly API (Invalid Auth request)'}]
07-26 20:18:06.549: W/System.err(639):  at com.twitvid.api.TwitvidApi.getJsonResponse(TwitvidApi.java:313)
07-26 20:18:06.549: W/System.err(639):  at com.twitvid.api.TwitvidApi.authenticate(TwitvidApi.java:29)
07-26 20:18:06.549: W/System.err(639):  at com.example.twitterintrgration.MainActivity.postToTwitvid(MainActivity.java:393)
07-26 20:18:06.549: W/System.err(639):  at com.example.twitterintrgration.MainActivity.access$3(MainActivity.java:379)
07-26 20:18:06.559: W/System.err(639):  at com.example.twitterintrgration.MainActivity$4.onClick(MainActivity.java:231)
07-26 20:18:06.559: W/System.err(639):  at android.view.View.performClick(View.java:2485)
07-26 20:18:06.559: W/System.err(639):  at android.view.View$PerformClick.run(View.java:9080)
07-26 20:18:06.559: W/System.err(639):  at android.os.Handler.handleCallback(Handler.java:587)
07-26 20:18:06.559: W/System.err(639):  at android.os.Handler.dispatchMessage(Handler.java:92)
07-26 20:18:06.569: W/System.err(639):  at android.os.Looper.loop(Looper.java:123)
07-26 20:18:06.569: W/System.err(639):  at android.app.ActivityThread.main(ActivityThread.java:3683)
07-26 20:18:06.569: W/System.err(639):  at java.lang.reflect.Method.invokeNative(Native Method)
07-26 20:18:06.569: W/System.err(639):  at java.lang.reflect.Method.invoke(Method.java:507)
07-26 20:18:06.569: W/System.err(639):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-26 20:18:06.569: W/System.err(639):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-26 20:18:06.569: W/System.err(639):  at dalvik.system.NativeStart.main(Native Method)

0 个答案:

没有答案