[twitter] Fix TwitterOauth library usage

- Use array result instead of object
This commit is contained in:
Hypolite Petovan 2018-02-07 20:19:22 -05:00
parent 29cf1539a7
commit 760abd8694
1 changed files with 7 additions and 13 deletions

View File

@ -288,34 +288,28 @@ function twitter_settings(App $a, &$s)
$s .= '</span>';
if ((!$ckey) && (!$csecret)) {
/* * *
* no global consumer keys
/* no global consumer keys
* display warning and skip personal config
*/
$s .= '<p>' . L10n::t('No consumer key pair for Twitter found. Please contact your site administrator.') . '</p>';
} else {
/* * *
* ok we have a consumer key pair now look into the OAuth stuff
*/
// ok we have a consumer key pair now look into the OAuth stuff
if ((!$otoken) && (!$osecret)) {
/* * *
* the user has not yet connected the account to twitter...
/* the user has not yet connected the account to twitter...
* get a temporary OAuth key/secret pair and display a button with
* which the user can request a PIN to connect the account to a
* account at Twitter.
*/
$connection = new TwitterOAuth($ckey, $csecret);
$result = $connection->oauth('oauth/request_token', ['oauth_callback' => 'oob']);
/* * *
* make some nice form
*/
$s .= '<p>' . L10n::t('At this Friendica instance the Twitter addon was enabled but you have not yet connected your account to your Twitter account. To do so click the button below to get a PIN from Twitter which you have to copy into the input box below and submit the form. Only your <strong>public</strong> posts will be posted to Twitter.') . '</p>';
$s .= '<a href="' . $connection->url('oauth/authorize', ['oauth_token' => $result->oauth_token]) . '" target="_twitter"><img src="addon/twitter/lighter.png" alt="' . L10n::t('Log in with Twitter') . '"></a>';
$s .= '<a href="' . $connection->url('oauth/authorize', ['oauth_token' => $result['oauth_token']]) . '" target="_twitter"><img src="addon/twitter/lighter.png" alt="' . L10n::t('Log in with Twitter') . '"></a>';
$s .= '<div id="twitter-pin-wrapper">';
$s .= '<label id="twitter-pin-label" for="twitter-pin">' . L10n::t('Copy the PIN from Twitter here') . '</label>';
$s .= '<input id="twitter-pin" type="text" name="twitter-pin" />';
$s .= '<input id="twitter-token" type="hidden" name="twitter-token" value="' . $result->oauth_token . '" />';
$s .= '<input id="twitter-token2" type="hidden" name="twitter-token2" value="' . $result->oauth_token_secret . '" />';
$s .= '<input id="twitter-token" type="hidden" name="twitter-token" value="' . $result['oauth_token'] . '" />';
$s .= '<input id="twitter-token2" type="hidden" name="twitter-token2" value="' . $result['oauth_token_secret'] . '" />';
$s .= '</div><div class="clear"></div>';
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . L10n::t('Save Settings') . '" /></div>';
} else {