【问题标题】:Twitter Follow Link推特关注链接
【发布时间】:2010-06-15 19:45:01
【问题描述】:

如何创建一个链接,如果用户已登录,则该链接将自动让用户关注某个 Twitter 用户,或者如果用户未登录,则将其发送到 Twitter 以先登录?大约一个月或 2 个月前,我已经找到了如何执行此操作,但再也找不到了。我认为这是基本的东西,比如链接或表单帖子,比如 twitter.com/[user]/follow。

我查看了 API,但我需要用户在我的网站上进行身份验证,我不想处理这个问题。我只是希望他们直接在 Twitter 上进行身份验证,而不用担心。我找到的方法既好又简单,我只想再次找到它。

【问题讨论】:

  • 去检查你之前问题的一些正确答案,然后我们谈谈:P

标签: twitter


【解决方案1】:

使用 Twitter 的web intents

虽然您可以使用the follow button,但您也可以将用户直接发送到 Intent URL,如下所示:

https://twitter.com/intent/user?screen_name=NASA

【讨论】:

  • 网络意图的链接消失了。我建议this replacement
  • @showdev 欣赏;我已经更新了答案。
【解决方案2】:

how to use twitter api in my android application to implement follow button only

安卓

http://code.google.com/p/android-hackathon-in-fukuoka/source/browse/trunk/sodefuri/src/jp/jagfukuoka/sodefuri/TimeLineActivity.java?spec=svn167&r=167

代码片段:(我已将中文字符串转换为标准英语)

public class TimeLineActivity extends ListActivity {
        private TwitterPreferenceManager tpm = new TwitterPreferenceManager(this);  

        private static final int FOLLOW = 1;
        private static final CharSequence FOLLOW_LABEL = "Follow";

        @Override
        protected void onCreate(Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);

                // timeline Obtaining process
                String screenName = getIntent().getStringExtra("screen_name");
                List<String> list = this.getTimeLine(screenName);

                setListAdapter(new ArrayAdapter<String>(this, R.layout.timeline_item,list));
        }

        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
                menu.add(0, FOLLOW, 0, FOLLOW_LABEL);
                return super.onCreateOptionsMenu(menu);
        }

        @Override
        public boolean onOptionsItemSelected(MenuItem item) {
                switch (item.getItemId()) {
                case FOLLOW:
                        ConfigurationBuilder builder = new ConfigurationBuilder();
                        Configuration conf = builder.setOAuthAccessToken(tpm.getAccessToken())
                        .setOAuthAccessTokenSecret(tpm.getAccessTokenSercret())
                        .setOAuthConsumerKey(TwitterPreferenceManager.CONSUMER_KEY)
                        .setOAuthConsumerSecret(TwitterPreferenceManager.CONSUMER_SERCRET)
                        .setDebugEnabled(true)
                        .build();
                        Twitter twitter = new TwitterFactory(conf).getInstance();
                        try {
                                String screen_name = getIntent().getStringExtra("screen_name");
                                twitter.createFriendship(screen_name);
                                Toast.makeText(getApplicationContext(), "Was to follow.", Toast.LENGTH_LONG).show();
                        } catch (TwitterException e) {
                                Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
                                e.printStackTrace();
                        }
                        break;

                default:
                        break;
                }
                return super.onOptionsItemSelected(item);
        }

        /**
         * Get the time line for the specified user
         * 
         * @param screenName
         * @return
         */
        private List<String> getTimeLine(String screenName) {
                List<String> result = new ArrayList<String>();

                Twitter twitter = new TwitterFactory().getInstance();
                ResponseList<Status> userTimeline;
                try {
                        userTimeline = twitter.getUserTimeline(screenName);
                        for (Status status : userTimeline) {
                                result.add(status.getText());
                        }
                } catch (TwitterException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                return result;
        }
}

iPhone

http://www.chrismaddern.com/twitter-follow-button-for-ios-iphone-code/

这里是方法,怎么做

FollowMeButton 可以通过添加 UIButton 并将其类更改为 FollowMeButton 或在代码中使用自定义初始化程序在 Interface Builder 中创建:

[self.view addSubview:[[FollowMeButton alloc] initWithTwitterAccount:@"chrismaddern" atOrigin:CGPointMake(205, 248) isSmallButton:YES]];

通过在初始化程序中设置 isSmallButton 或稍后更改对象的 isSmall 属性来控制两种大小模式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-07
    • 2011-08-21
    • 1970-01-01
    • 2011-01-04
    • 2012-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多