【问题标题】:Posting data from android app on my Twitter's account as tweet将来自 android 应用程序的数据作为推文发布到我的 Twitter 帐户上
【发布时间】:2014-01-16 15:33:37
【问题描述】:

我正在尝试通过我的 twitter 帐户上的 android 应用程序发布我的数据,所以我应该怎么做。 我尝试了一种方法,下面是代码,它显示了我帐户上的数据,我需要单击推文按钮才能将其发布推文。所以我可以知道如何在不要求我发推文的情况下直接发布它。点赞Four Squareapp

public void open(View view){
       String text = "Share Your Experiance ....!!!";
       String url = "twitter://post?message=";

       try {
           Intent i = new Intent(Intent.ACTION_VIEW);
           i.setData(Uri.parse(url + Uri.encode(text)));
           startActivity(i);
       } catch (android.content.ActivityNotFoundException e) {
           Toast.makeText(this, "Can't send tweet! Please install twitter...", 2).show();
       }

提前致谢!!!

【问题讨论】:

  • 使用社交认证库

标签: android twitter


【解决方案1】:

首先,您必须检查您是否使用 twitter 登录,因为您可以应用此 sn-p 代码。

我认为您在代码中遵循了 twitter 集成的所有基础知识。

public void uploadPic(String message, String getImgUrl)
        throws Exception {
        try {
            System.out.println(" ON UPLOAD PIC FUNCTION getImgUrl "+getImgUrl);
            // URL url = new URL("http://faveplatewebservice.siplstudio.com/uploads/big_dish/oooo14n7464rO4_thumb.png");
            URL url = new URL(getImgUrl);
            URLConnection urlConnection = url.openConnection();
            InputStream in = new BufferedInputStream(urlConnection.getInputStream());

            StatusUpdate status = new StatusUpdate("Check Out FavPlates on appstore, which offers you to add and find exciting dishes near you. "+message);
            //status.setMedia(file);
            status.setMedia("Check Out FavPlates on appstore, which offers you to add and find exciting dishes near you. "+message, in);

            mTwitter.updateStatus(status);
        } catch (TwitterException e) {
            Log.d("TAG", "Pic Upload error" + e.getExceptionCode());
            throw e;
        }
    }

希望对你有帮助!!

如果你卡在任何地方,请告诉我。

谢谢!!

【讨论】:

    猜你喜欢
    • 2012-05-03
    • 2021-09-20
    • 1970-01-01
    • 2019-03-06
    • 2014-10-24
    • 1970-01-01
    • 2013-09-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多