2017-12-18 289 views
0

在我的應用程序到目前爲止,我使用Android的Twitter工具包顯示推文(我現在自己的),並有一個轉推按鈕,我正在嘗試(去圖)使用Twitter API客戶端轉發。Twitter Kit Android - TwitterApiClient轉推不起作用

下面是我在這之前提到的鏈接:

1) Twitter REST APIs from Android

2) Twitter Community Discussion on Retweeting using the TwitterApiClient

這是我使用的代碼:

val twApiClient: TwitterApiClient = TwitterCore.getInstance().apiClient 
    tbTweet.setOnMenuItemClickListener { 
     when (it.itemId) { 
      R.id.item_retweet -> { 
       val call: Call<Tweet> = twApiClient.statusesService.retweet(tweetID, true) 
       Log.i("Retweet", if (call.isExecuted) "Successful" else "Failed") 
      } 
     } 
     true 
    } 

我沒有得到任何錯誤,但當我在twitter上轉到我的個人資料頁面時,轉發不顯示。在我提供的第二條鏈接中也提到了同樣的問題,但沒有給出解決方案。

我也註銷執行狀態。它來作爲「失敗」,所以我知道電話retweet()甚至沒有執行。但爲什麼?

有什麼問題,我該如何解決?

回答

0

所以,顯然上面的代碼是不完整的。您必須從retweet(tweetId, true)方法返回的呼叫對象上調用​​。然後,您可以撥打onCompleteListener以查看您的轉推是否成功。