I am not able to post twitter card to twitter application?I am not able to find error?



Here is code:

    protected void onCreate(Bundle savedInstanceState) {
        TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
        Fabric.with(this, new Twitter(authConfig));
        Fabric.with(this, new TwitterCore(authConfig), new TweetUi());
        Fabric.with(this, new TwitterCore(authConfig), new TweetComposer(), new Crashlytics());
        textView = (TextView) findViewById(R.id.tv_username);
        loginButton = (TwitterLoginButton) findViewById(R.id.twitter_login_button);
        loginButton.setCallback(new Callback<TwitterSession>() {

            public void success(Result<TwitterSession> result) {
                session = result.data;
                String username = session.getUserName();
                userid = session.getUserId();
                final TwitterSession session = TwitterCore.getInstance().getSessionManager().getActiveSession();
                final Card card = new Card.AppCardBuilder(MainActivityextend.this)
                final Intent intent = new ComposerActivity.Builder(MainActivityextend.this)
            public void failure(TwitterException exception) {

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        loginButton.onActivityResult(requestCode, resultCode, data);


Can you provide any more detail here - what is the issue, error, or unexpected behaviour you are seeing with this code?


There is no error in the application.Twitter card is easily created but when i clicked on tweet button then it will not sending post to twitter.


Hey @Nati078626,

Has your package name been approved to post cards to Twitter?



Yes approved but still getting error

Unexpected response: {"request":"\/1.1\/statuses\/update.json","error":"Read-only application cannot POST."}
                                                                   java.lang.NullPointerException: Attempt to get length of null array
                                                                       at com.twitter.sdk.android.core.Callback.failure(Callback.java:45)
                                                                       at retrofit.CallbackRunnable$2.run(CallbackRunnable.java:53)
                                                                       at android.os.Handler.handleCallback(Handler.java:810)
                                                                       at android.os.Handler.dispatchMessage(Handler.java:99)
                                                                       at android.os.Looper.loop(Looper.java:189)
                                                                       at android.app.ActivityThread.main(ActivityThread.java:5530)
                                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:950)
                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
09-06 11:06:08.138 11838-11838/com.votesocracy.twitter2 E/TweetUploadService: Post Tweet failed
                                                                              com.twitter.sdk.android.core.TwitterApiException: 401 Authorization Required
                                                                                  at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:383)
                                                                                  at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
                                                                                  at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
                                                                                  at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
                                                                                  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
                                                                                  at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                                  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
                                                                                  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
                                                                                  at java.lang.Thread.run(Thread.java:818)
09-06 11:06:52.895 11838-11838/com.votesocracy.twitter2 E/TweetFailureReceiver: Intent { cmp=com.votesocracy.twitter2/com.twitter.sdk.android.tweetcomposer.TweetUploadService (has extras) }


That sounds weird, it looks like your application does not have read/write permissions on Twitter. Was your application key created via Fabric, or are you pasting it in from apps.twitter.com?


I changed my acess token key and secret key,Now everything is working fine twitter card is created easily but when i clicked the tweet button it just only post the text not the twitter card and i am not finding any error ?What is the issue.


I’m not familiar with the way that this is intended to work in the TweetComposer in Fabric, but when the Tweet is posted, does the card appear? With regular cards on the web, the card does not appear in the web intent composer, just in the final rendered Tweet.


I am sending twitter card from my android application.When i create twitter card its working fine created successfully,but when I clicked tweet button,Just text is posted but twitter card is not showing in android application nor in the web.


Help me Please Andypiper?


Hmm, the previous logs and post seem to indicate that something very odd is happening. Can you please email into support(at)fabric(dot)io, reference this thread and provide your Twitter Consumer Key?


I am sharing you github link(https://github.com/actimobiledev/Twittersud) where you could find whole source code of application.Through this you can check the exact issue?


It looks like your app’s key doesn’t have the correct permissions. Given that the keys are now public, they need to be revoked and re-created. Your Twitter Consumer Key and Fabric API key should not be made public.

If you head to your Fabric dashboard, you generate a new key there for Twitter Kit. After you do that, please email into support(at)fabric(dot)io, reference this thread and I can check to make sure you have the needed permissions.