X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=twitter%2Ftwitter.php;h=cc12e8de8448dad7a223358b27fde337e35e6400;hb=e4f32f8ac8dbee577dc31195b1104add371f77eb;hp=50239b8bef54cb670dce859ad088f8fb77152ad5;hpb=01738518a25392aefea8586463121024ae3a1a4c;p=friendica-addons.git
diff --git a/twitter/twitter.php b/twitter/twitter.php
index 50239b8b..cc12e8de 100644
--- a/twitter/twitter.php
+++ b/twitter/twitter.php
@@ -72,18 +72,20 @@ use Friendica\Core\PConfig;
use Friendica\Core\Worker;
use Friendica\Model\GContact;
use Friendica\Model\Group;
+use Friendica\Model\Item;
use Friendica\Model\Photo;
use Friendica\Model\Queue;
use Friendica\Model\User;
use Friendica\Object\Image;
use Friendica\Util\Network;
+use Friendica\Util\Temporal;
require_once 'boot.php';
require_once 'include/dba.php';
require_once 'include/enotify.php';
require_once 'include/text.php';
-require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
+require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
define('TWITTER_DEFAULT_POLL_INTERVAL', 5); // given in minutes
@@ -157,6 +159,12 @@ function twitter_follow(App $a, &$contact)
$otoken = PConfig::get($uid, 'twitter', 'oauthtoken');
$osecret = PConfig::get($uid, 'twitter', 'oauthsecret');
+ // If the addon is not configured (general or for this user) quit here
+ if (empty($ckey) || empty($csecret) || empty($otoken) || empty($osecret)) {
+ $contact = false;
+ return;
+ }
+
$connection = new TwitterOAuth($ckey, $csecret, $otoken, $osecret);
$connection->post('friendships/create', ['screen_name' => $nickname]);
@@ -222,7 +230,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']);
@@ -297,18 +305,17 @@ function twitter_settings(App $a, &$s)
* account at Twitter.
*/
$connection = new TwitterOAuth($ckey, $csecret);
- $request_token = $connection->getRequestToken();
- $token = $request_token['oauth_token'];
+ $result = $connection->oauth('oauth/request_token', ['oauth_callback' => 'oob']);
/* * *
* make some nice form
*/
$s .= '
' . 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 public posts will be posted to Twitter.') . '