aboutsummaryrefslogtreecommitdiffstats
path: root/addon/twitter/twitter.php
diff options
context:
space:
mode:
authorfabrixxm <fabrix.xm@gmail.com>2011-01-03 09:45:13 +0100
committerfabrixxm <fabrix.xm@gmail.com>2011-01-03 09:45:13 +0100
commit43283fd35fb9987a1554612220f11a0875697bd4 (patch)
tree2e9db966f98a1187c6be74998ebd2905fe0a8c39 /addon/twitter/twitter.php
parentdcaf4003eca3fe4f958760587eefea52b171fab3 (diff)
parentd92659560b8edd0594b587103b43ad5bd5012639 (diff)
downloadvolse-hubzilla-43283fd35fb9987a1554612220f11a0875697bd4.tar.gz
volse-hubzilla-43283fd35fb9987a1554612220f11a0875697bd4.tar.bz2
volse-hubzilla-43283fd35fb9987a1554612220f11a0875697bd4.zip
Merge branch 'friendika-master'
Diffstat (limited to 'addon/twitter/twitter.php')
-rw-r--r--addon/twitter/twitter.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/addon/twitter/twitter.php b/addon/twitter/twitter.php
new file mode 100644
index 000000000..9fccefbee
--- /dev/null
+++ b/addon/twitter/twitter.php
@@ -0,0 +1,46 @@
+<?php
+
+
+function twitter_install() {
+ register_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
+}
+
+
+function twitter_uninstall() {
+ unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
+}
+
+
+
+
+function twitter_post_hook(&$a,&$b) {
+
+ /**
+ * Post to Twitter
+ */
+
+ if((local_user()) && (local_user() == $b['uid']) && (! $b['private'])) {
+
+ load_pconfig(local_user(), 'twitter');
+
+ $ckey = get_pconfig(local_user(), 'twitter', 'consumerkey' );
+ $csecret = get_pconfig(local_user(), 'twitter', 'consumersecret' );
+ $otoken = get_pconfig(local_user(), 'twitter', 'oauthtoken' );
+ $osecret = get_pconfig(local_user(), 'twitter', 'oauthsecret' );
+
+ if($ckey && $csecret && $otoken && $osecret) {
+
+ $twitter_post = get_pconfig(local_user(),'twitter','post');
+
+ if($twitter_post) {
+ require_once('addon/twitter/twitteroauth.php');
+ require_once('include/bbcode.php');
+
+ $tweet = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
+ $tweet->post('statuses/update', array('status' => bbcode($b['body'])));
+ }
+ }
+ }
+}
+
+