diff options
author | Cash Costello <cash.costello@gmail.com> | 2013-04-16 15:59:54 -0700 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2013-04-16 15:59:54 -0700 |
commit | c054b938e972b6f31c1f95a469b1220a6c25628e (patch) | |
tree | 87aa97a77f3ef4c47e09cd06ac376f8e069c38fb /mod/twitter_api/start.php | |
parent | 9dc21d3970b9f6e56438ae2f8875b1c8bec40e03 (diff) | |
parent | 9c3d423d87fe5f287a48158df105364b6eb36de0 (diff) | |
download | elgg-c054b938e972b6f31c1f95a469b1220a6c25628e.tar.gz elgg-c054b938e972b6f31c1f95a469b1220a6c25628e.tar.bz2 |
Merge pull request #5360 from cash/twitter1.1
Twitter API 1.1 update
Diffstat (limited to 'mod/twitter_api/start.php')
-rw-r--r-- | mod/twitter_api/start.php | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/mod/twitter_api/start.php b/mod/twitter_api/start.php index e6221de6b..e3e866c1f 100644 --- a/mod/twitter_api/start.php +++ b/mod/twitter_api/start.php @@ -115,13 +115,6 @@ function twitter_api_tweet($hook, $type, $returnvalue, $params) { // @todo - allow admin to select origins? - // check admin settings - $consumer_key = elgg_get_plugin_setting('consumer_key', 'twitter_api'); - $consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitter_api'); - if (!($consumer_key && $consumer_secret)) { - return; - } - // check user settings $user_id = $params['user']->getGUID(); $access_key = elgg_get_plugin_user_setting('access_key', $user_id, 'twitter_api'); @@ -130,8 +123,11 @@ function twitter_api_tweet($hook, $type, $returnvalue, $params) { return; } - // send tweet - $api = new TwitterOAuth($consumer_key, $consumer_secret, $access_key, $access_secret); + $api = twitter_api_get_api_object($access_key, $access_secret); + if (!$api) { + return; + } + $api->post('statuses/update', array('status' => $params['message'])); } @@ -143,12 +139,6 @@ function twitter_api_tweet($hook, $type, $returnvalue, $params) { * @return array */ function twitter_api_fetch_tweets($user_guid, $options = array()) { - // check admin settings - $consumer_key = elgg_get_plugin_setting('consumer_key', 'twitter_api'); - $consumer_secret = elgg_get_plugin_setting('consumer_secret', 'twitter_api'); - if (!($consumer_key && $consumer_secret)) { - return FALSE; - } // check user settings $access_key = elgg_get_plugin_user_setting('access_key', $user_guid, 'twitter_api'); @@ -157,8 +147,11 @@ function twitter_api_fetch_tweets($user_guid, $options = array()) { return FALSE; } - // fetch tweets - $api = new TwitterOAuth($consumer_key, $consumer_secret, $access_key, $access_secret); + $api = twitter_api_get_api_object($access_key, $access_secret); + if (!$api) { + return FALSE; + } + return $api->get('statuses/user_timeline', $options); } |