Merge pull request #511 from MrPetovan/task/4116-move-twitteroauth-to-composer

Upgrade TwitterOAuth calls in twitter addon
pull/513/head
Michael Vogel 2018-01-29 14:50:10 +01:00 committed by GitHub
commit 5e88657095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -223,7 +223,7 @@ function twitter_settings_post(App $a, $post)
// form as token and token2, we need a new connection to Twitter using these token
// and secret to request a Access Token with the PIN
$connection = new TwitterOAuth($ckey, $csecret, $_POST['twitter-token'], $_POST['twitter-token2']);
$token = $connection->getAccessToken($_POST['twitter-pin']);
$token = $connection->oauth("oauth/access_token", ["oauth_verifier" => $_POST['twitter-pin']]);
// ok, now that we have the Access Token, save them in the user config
PConfig::set(local_user(), 'twitter', 'oauthtoken', $token['oauth_token']);
PConfig::set(local_user(), 'twitter', 'oauthsecret', $token['oauth_token_secret']);
@ -298,17 +298,16 @@ function twitter_settings(App $a, &$s)
* account at Twitter.
*/
$connection = new TwitterOAuth($ckey, $csecret);
$request_token = $connection->getRequestToken();
$token = $request_token['oauth_token'];
$request_token = $connection->url('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->getAuthorizeURL($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' => $request_token['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="' . $token . '" />';
$s .= '<input id="twitter-token" type="hidden" name="twitter-token" value="' . $request_token['oauth_token'] . '" />';
$s .= '<input id="twitter-token2" type="hidden" name="twitter-token2" value="' . $request_token['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>';