0

私のアプリでは、別のユーザーのタイムラインからのツイートを表示したいと思います。それは可能ですか?authを必要としないuser_timelinesにアクセスできますが、home_timelinesの場合はauthを実行する必要がありますが、別のユーザーのパブリックタイムラインを読み取るにはどうすればよいですか?

4

1 に答える 1

0

特定のユーザーのhome_timelineからツイートを取得する場合は、認証する必要があります。残念ながら、最善の策は、おそらくデバイスでアカウントを承認して取得することです。ただし、これは難しい作業ではありません。以下は、アカウントへのアクセスを要求するためにTwitterアプリケーションで使用したコードです。

    // Create an account store object.
    ACAccountStore *accountStore = [[ACAccountStore alloc] init];

    // Create an account type that ensures Twitter accounts are retrieved.
    ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];

    // Request access from the user to use their Twitter accounts.
    [accountStore requestAccessToAccountsWithType:accountType options:nil completion:^(BOOL granted, NSError *error) {

        if(granted) {
            // Get the list of Twitter accounts.
            NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];

            // For the sake of brevity, we'll assume there is only one Twitter account present.
            // You would ideally ask the user which account they want to tweet from, if there is more than one Twitter account present.
            if ([accountsArray count] > 0) {
                // Grab the initial Twitter account to tweet from.
                ACAccount *twitterAccount = [accountsArray objectAtIndex:0];

                //At this point, the twitterAccount has been pulled into the *twitterAccount object.
            }
        }

編集:以下のコメントによると、 twitter.comhome_timeline / BBCNewsに表示されるものと同様に、BBC から表示したいと考えています。home_timeline API呼び出しは、現在認証されているアカウントのタイムラインのみを返します。これは、アプリケーションを使用しているユーザーのタイムラインのみを取得できることを意味します。

BBCNewsなど、別のユーザーのタイムラインを取得する場合は、twitterapiアカウントのタイムラインを選択するtwitterの例と同様に、 user_timeline API呼び出しを使用して、タイムラインが必要なユーザーをパラメーターで指定する必要があります。

さらに、その音からするとuser_timeline、リツイートも表示したいので、API呼び出しは機能しません。ドキュメントを見ると、API呼び出しで使用できるオプションのパラメーターがinclude_rtsあり、リツイートを含めたり除外したりできます。

これはあなたの問題を解決します。過去にTwitterAPIを使って問題が発生したことがよくありましたが、「私が直面している問題は単純な問題ですか?」と自問していました。実際に直面している問題が本当に単純な場合は、問題がすでに処理または解決されている可能性があり、解決策が見つからないので安心できます。それをクラックし続けます。 user_timeline使用したいものです。パラメータをいじってみてください。

于 2012-11-06T12:05:02.823 に答える