mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-25 09:23:41 +00:00
Merge pull request #199 from annando/master
app.net/expire of facebook and twitter posts
This commit is contained in:
commit
ec8384df66
11 changed files with 3241 additions and 443 deletions
1647
appnet/AppDotNet.php
Normal file
1647
appnet/AppDotNet.php
Normal file
File diff suppressed because it is too large
Load diff
23
appnet/DigiCertHighAssuranceEVRootCA.pem
Normal file
23
appnet/DigiCertHighAssuranceEVRootCA.pem
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBs
|
||||||
|
MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
|
||||||
|
d3cuZGlnaWNlcnQuY29tMSswKQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5j
|
||||||
|
ZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAwMFoXDTMxMTExMDAwMDAwMFowbDEL
|
||||||
|
MAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZMBcGA1UECxMQd3d3
|
||||||
|
LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFuY2Ug
|
||||||
|
RVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm
|
||||||
|
+9S75S0tMqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTW
|
||||||
|
PNt0OKRKzE0lgvdKpVMSOO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEM
|
||||||
|
xChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFB
|
||||||
|
Ik5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQNAQTXKFx01p8VdteZOE3
|
||||||
|
hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUeh10aUAsg
|
||||||
|
EsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQF
|
||||||
|
MAMBAf8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaA
|
||||||
|
FLE+w2kD+L9HAdSYJhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3Nec
|
||||||
|
nzyIZgYIVyHbIUf4KmeqvxgydkAQV8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6z
|
||||||
|
eM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFpmyPInngiK3BD41VHMWEZ71jF
|
||||||
|
hS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkKmNEVX58Svnw2
|
||||||
|
Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
|
||||||
|
vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep
|
||||||
|
+OkuE6N36B9K
|
||||||
|
-----END CERTIFICATE-----
|
29
appnet/appnet.css
Executable file
29
appnet/appnet.css
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
#appnet-import-label, #appnet-disconnect-label, #appnet-token-label,
|
||||||
|
#appnet-enable-label, #appnet-bydefault-label,
|
||||||
|
#appnet-clientid-label, #appnet-clientsecret-label {
|
||||||
|
float: left;
|
||||||
|
width: 200px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#appnet-import, #appnet-disconnect, #appnet-token,
|
||||||
|
#appnet-checkbox, #appnet-bydefault,
|
||||||
|
#appnet-clientid, #appnet-clientsecret {
|
||||||
|
float: left;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#appnet-submit {
|
||||||
|
margin-top: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#appnet-avatar {
|
||||||
|
float: left;
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
#appnet-info-block {
|
||||||
|
height: 52px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
1047
appnet/appnet.php
Normal file
1047
appnet/appnet.php
Normal file
File diff suppressed because it is too large
Load diff
0
appnetpost/appnetpost.css
Executable file → Normal file
0
appnetpost/appnetpost.css
Executable file → Normal file
|
@ -69,7 +69,7 @@ function fbpost_init(&$a) {
|
||||||
|
|
||||||
if(strlen($nick))
|
if(strlen($nick))
|
||||||
$r = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
|
$r = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1",
|
||||||
dbesc($nick)
|
dbesc($nick)
|
||||||
);
|
);
|
||||||
if(!(isset($r) && count($r)))
|
if(!(isset($r) && count($r)))
|
||||||
return;
|
return;
|
||||||
|
@ -154,7 +154,7 @@ function fbpost_post(&$a) {
|
||||||
$result = q("SELECT `installed` FROM `addon` WHERE `name` = 'fbsync' AND `installed`");
|
$result = q("SELECT `installed` FROM `addon` WHERE `name` = 'fbsync' AND `installed`");
|
||||||
if (count($result) > 0) {
|
if (count($result) > 0) {
|
||||||
set_pconfig(local_user(),'fbsync','sync',intval($_POST['fbsync']));
|
set_pconfig(local_user(),'fbsync','sync',intval($_POST['fbsync']));
|
||||||
set_pconfig(local_user(),'fbsync','create_user',intval($_POST['create_user']));
|
set_pconfig(local_user(),'fbsync','create_user',intval($_POST['create_user']));
|
||||||
}
|
}
|
||||||
|
|
||||||
info( t('Settings updated.') . EOL);
|
info( t('Settings updated.') . EOL);
|
||||||
|
@ -248,7 +248,7 @@ function fbpost_content(&$a) {
|
||||||
//read_stream,publish_stream,manage_pages,photo_upload,user_groups,offline_access
|
//read_stream,publish_stream,manage_pages,photo_upload,user_groups,offline_access
|
||||||
|
|
||||||
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
|
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
|
||||||
. $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=export_stream,read_stream,publish_stream,manage_pages,photo_upload,user_groups,publish_actions,user_friends,create_note,share_item,video_upload,status_update">' . t('Install Facebook Post connector for this account.') . '</a>';
|
. $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=export_stream,read_stream,publish_stream,manage_pages,photo_upload,user_groups,publish_actions,user_friends,share_item,video_upload,status_update">' . t('Install Facebook Post connector for this account.') . '</a>';
|
||||||
$o .= '</div>';
|
$o .= '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ function fbpost_content(&$a) {
|
||||||
$o .= '<div id="fbpost-enable-wrapper">';
|
$o .= '<div id="fbpost-enable-wrapper">';
|
||||||
|
|
||||||
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
|
$o .= '<a href="https://www.facebook.com/dialog/oauth?client_id=' . $appid . '&redirect_uri='
|
||||||
. $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=export_stream,read_stream,publish_stream,manage_pages,photo_upload,user_groups,publish_actions,user_friends,create_note,share_item,video_upload,status_update">' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . '</a>';
|
. $a->get_baseurl() . '/fbpost/' . $a->user['nickname'] . '&scope=export_stream,read_stream,publish_stream,manage_pages,photo_upload,user_groups,publish_actions,user_friends,share_item,video_upload,status_update">' . t('Re-authenticate [This is necessary whenever your Facebook password is changed.]') . '</a>';
|
||||||
$o .= '</div>';
|
$o .= '</div>';
|
||||||
|
|
||||||
$o .= '<div id="fbpost-post-default-form">';
|
$o .= '<div id="fbpost-post-default-form">';
|
||||||
|
@ -316,11 +316,11 @@ function fbpost_content(&$a) {
|
||||||
|
|
||||||
$o .= '<div class="clear"></div>';
|
$o .= '<div class="clear"></div>';
|
||||||
|
|
||||||
$sync_enabled = get_pconfig(local_user(),'fbsync','sync');
|
$sync_enabled = get_pconfig(local_user(),'fbsync','sync');
|
||||||
$checked = (($sync_enabled) ? ' checked="checked" ' : '');
|
$checked = (($sync_enabled) ? ' checked="checked" ' : '');
|
||||||
$o .= '<input type="checkbox" name="fbsync" value="1"' . $checked . '/>' . ' ' . t('Import Facebook newsfeed.') . EOL;
|
$o .= '<input type="checkbox" name="fbsync" value="1"' . $checked . '/>' . ' ' . t('Import Facebook newsfeed.') . EOL;
|
||||||
|
|
||||||
$create_user = get_pconfig(local_user(),'fbsync','create_user');
|
$create_user = get_pconfig(local_user(),'fbsync','create_user');
|
||||||
$checked = (($create_user) ? ' checked="checked" ' : '');
|
$checked = (($create_user) ? ' checked="checked" ' : '');
|
||||||
$o .= '<input type="checkbox" name="create_user" value="1"' . $checked . '/>' . ' ' . t('Automatically create contacts.') . EOL;
|
$o .= '<input type="checkbox" name="create_user" value="1"' . $checked . '/>' . ' ' . t('Automatically create contacts.') . EOL;
|
||||||
|
|
||||||
|
@ -666,11 +666,13 @@ function fbpost_post_hook(&$a,&$b) {
|
||||||
$postvars['message'] = $msg;
|
$postvars['message'] = $msg;
|
||||||
|
|
||||||
$url = 'https://graph.facebook.com/'.$target.'/photos';
|
$url = 'https://graph.facebook.com/'.$target.'/photos';
|
||||||
} else if (($link != "") or ($image != "") or ($b['title'] == '') or (strlen($msg) < 500)) {
|
//} else if (($link != "") or ($image != "") or ($b['title'] == '') or (strlen($msg) < 500)) {
|
||||||
|
} else {
|
||||||
$url = 'https://graph.facebook.com/'.$target.'/feed';
|
$url = 'https://graph.facebook.com/'.$target.'/feed';
|
||||||
if (!get_pconfig($b['uid'],'facebook','suppress_view_on_friendica') and $b['plink'])
|
if (!get_pconfig($b['uid'],'facebook','suppress_view_on_friendica') and $b['plink'])
|
||||||
$postvars['actions'] = '{"name": "' . t('View on Friendica') . '", "link": "' . $b['plink'] . '"}';
|
$postvars['actions'] = '{"name": "' . t('View on Friendica') . '", "link": "' . $b['plink'] . '"}';
|
||||||
} else {
|
}
|
||||||
|
/* } else {
|
||||||
// if its only a message and a subject and the message is larger than 500 characters then post it as note
|
// if its only a message and a subject and the message is larger than 500 characters then post it as note
|
||||||
$postvars = array(
|
$postvars = array(
|
||||||
'access_token' => $fb_token,
|
'access_token' => $fb_token,
|
||||||
|
@ -678,7 +680,7 @@ function fbpost_post_hook(&$a,&$b) {
|
||||||
'subject' => $b['title'],
|
'subject' => $b['title'],
|
||||||
);
|
);
|
||||||
$url = 'https://graph.facebook.com/'.$target.'/notes';
|
$url = 'https://graph.facebook.com/'.$target.'/notes';
|
||||||
}
|
} */
|
||||||
|
|
||||||
// Post to page?
|
// Post to page?
|
||||||
if (!$reply and ($target != "me") and $page_access_token)
|
if (!$reply and ($target != "me") and $page_access_token)
|
||||||
|
@ -946,6 +948,7 @@ function fbpost_cron($a,$b) {
|
||||||
|
|
||||||
function fbpost_fetchwall($a, $uid) {
|
function fbpost_fetchwall($a, $uid) {
|
||||||
require_once("include/oembed.php");
|
require_once("include/oembed.php");
|
||||||
|
require_once('mod/item.php');
|
||||||
|
|
||||||
$access_token = get_pconfig($uid,'facebook','access_token');
|
$access_token = get_pconfig($uid,'facebook','access_token');
|
||||||
$post_to_page = get_pconfig($uid,'facebook','post_to_page');
|
$post_to_page = get_pconfig($uid,'facebook','post_to_page');
|
||||||
|
@ -1081,8 +1084,6 @@ function fbpost_fetchwall($a, $uid) {
|
||||||
|
|
||||||
//print_r($_REQUEST);
|
//print_r($_REQUEST);
|
||||||
logger('facebook: posting for user '.$uid);
|
logger('facebook: posting for user '.$uid);
|
||||||
|
|
||||||
require_once('mod/item.php');
|
|
||||||
item_post($a);
|
item_post($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ function fbsync_install() {
|
||||||
register_hook('connector_settings_post', 'addon/fbsync/fbsync.php', 'fbsync_settings_post');
|
register_hook('connector_settings_post', 'addon/fbsync/fbsync.php', 'fbsync_settings_post');
|
||||||
register_hook('cron', 'addon/fbsync/fbsync.php', 'fbsync_cron');
|
register_hook('cron', 'addon/fbsync/fbsync.php', 'fbsync_cron');
|
||||||
register_hook('follow', 'addon/fbsync/fbsync.php', 'fbsync_follow');
|
register_hook('follow', 'addon/fbsync/fbsync.php', 'fbsync_follow');
|
||||||
|
register_hook('expire', 'addon/fbsync/fbsync.php', 'fbsync_expire');
|
||||||
}
|
}
|
||||||
|
|
||||||
function fbsync_uninstall() {
|
function fbsync_uninstall() {
|
||||||
|
@ -33,6 +34,7 @@ function fbsync_uninstall() {
|
||||||
unregister_hook('connector_settings_post', 'addon/fbsync/fbsync.php', 'fbsync_settings_post');
|
unregister_hook('connector_settings_post', 'addon/fbsync/fbsync.php', 'fbsync_settings_post');
|
||||||
unregister_hook('cron', 'addon/fbsync/fbsync.php', 'fbsync_cron');
|
unregister_hook('cron', 'addon/fbsync/fbsync.php', 'fbsync_cron');
|
||||||
unregister_hook('follow', 'addon/fbsync/fbsync.php', 'fbsync_follow');
|
unregister_hook('follow', 'addon/fbsync/fbsync.php', 'fbsync_follow');
|
||||||
|
unregister_hook('expire', 'addon/fbsync/fbsync.php', 'fbsync_expire');
|
||||||
}
|
}
|
||||||
|
|
||||||
function fbsync_follow($a, &$contact) {
|
function fbsync_follow($a, &$contact) {
|
||||||
|
@ -185,6 +187,30 @@ function fbsync_cron($a,$b) {
|
||||||
set_config('fbsync','last_poll', time());
|
set_config('fbsync','last_poll', time());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fbsync_expire($a,$b) {
|
||||||
|
|
||||||
|
$days = get_config('fbsync', 'expire');
|
||||||
|
|
||||||
|
if ($days == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$r = q("DELETE FROM `item` WHERE `deleted` AND `network` = '%s'", dbesc(NETWORK_FACEBOOK));
|
||||||
|
|
||||||
|
require_once("include/items.php");
|
||||||
|
|
||||||
|
logger('fbsync_expire: expire_start');
|
||||||
|
|
||||||
|
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'fbsync' AND `k` = 'sync' AND `v` = '1' ORDER BY RAND()");
|
||||||
|
if(count($r)) {
|
||||||
|
foreach($r as $rr) {
|
||||||
|
logger('fbsync_expire: user '.$rr['uid']);
|
||||||
|
item_expire($rr['uid'], $days, NETWORK_FACEBOOK, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger('fbsync_expire: expire_end');
|
||||||
|
}
|
||||||
|
|
||||||
function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $create_user) {
|
function fbsync_createpost($a, $uid, $self, $contacts, $applications, $post, $create_user) {
|
||||||
|
|
||||||
require_once("include/oembed.php");
|
require_once("include/oembed.php");
|
||||||
|
@ -1018,7 +1044,6 @@ function fbsync_fetchfeed($a, $uid) {
|
||||||
foreach ($post_data AS $post) {
|
foreach ($post_data AS $post) {
|
||||||
if ($post->updated_time > $last_updated)
|
if ($post->updated_time > $last_updated)
|
||||||
$last_updated = $post->updated_time;
|
$last_updated = $post->updated_time;
|
||||||
|
|
||||||
fbsync_createpost($a, $uid, $self, $contacts, $application_data, $post, $create_user);
|
fbsync_createpost($a, $uid, $self, $contacts, $application_data, $post, $create_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
355
pumpio/pumpio.php
Executable file → Normal file
355
pumpio/pumpio.php
Executable file → Normal file
|
@ -11,23 +11,23 @@ require('addon/pumpio/oauth/oauth_client.php');
|
||||||
define('PUMPIO_DEFAULT_POLL_INTERVAL', 5); // given in minutes
|
define('PUMPIO_DEFAULT_POLL_INTERVAL', 5); // given in minutes
|
||||||
|
|
||||||
function pumpio_install() {
|
function pumpio_install() {
|
||||||
register_hook('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
|
register_hook('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
|
||||||
register_hook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
|
register_hook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
|
||||||
register_hook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
|
register_hook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
|
||||||
register_hook('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
|
register_hook('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
|
||||||
register_hook('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
register_hook('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
||||||
register_hook('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
register_hook('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
||||||
register_hook('queue_predeliver', 'addon/pumpio/pumpio.php', 'pumpio_queue_hook');
|
register_hook('queue_predeliver', 'addon/pumpio/pumpio.php', 'pumpio_queue_hook');
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_uninstall() {
|
function pumpio_uninstall() {
|
||||||
unregister_hook('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
|
unregister_hook('post_local', 'addon/pumpio/pumpio.php', 'pumpio_post_local');
|
||||||
unregister_hook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
|
unregister_hook('notifier_normal', 'addon/pumpio/pumpio.php', 'pumpio_send');
|
||||||
unregister_hook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
|
unregister_hook('jot_networks', 'addon/pumpio/pumpio.php', 'pumpio_jot_nets');
|
||||||
unregister_hook('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
|
unregister_hook('connector_settings', 'addon/pumpio/pumpio.php', 'pumpio_settings');
|
||||||
unregister_hook('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
unregister_hook('connector_settings_post', 'addon/pumpio/pumpio.php', 'pumpio_settings_post');
|
||||||
unregister_hook('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
unregister_hook('cron', 'addon/pumpio/pumpio.php', 'pumpio_cron');
|
||||||
unregister_hook('queue_predeliver', 'addon/pumpio/pumpio.php', 'pumpio_queue_hook');
|
unregister_hook('queue_predeliver', 'addon/pumpio/pumpio.php', 'pumpio_queue_hook');
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_module() {}
|
function pumpio_module() {}
|
||||||
|
@ -61,37 +61,37 @@ function pumpio_registerclient(&$a, $host) {
|
||||||
|
|
||||||
$url = "https://".$host."/api/client/register";
|
$url = "https://".$host."/api/client/register";
|
||||||
|
|
||||||
$params = array();
|
$params = array();
|
||||||
|
|
||||||
$application_name = get_config('pumpio', 'application_name');
|
$application_name = get_config('pumpio', 'application_name');
|
||||||
|
|
||||||
if ($application_name == "")
|
if ($application_name == "")
|
||||||
$application_name = $a->get_hostname();
|
$application_name = $a->get_hostname();
|
||||||
|
|
||||||
$params["type"] = "client_associate";
|
$params["type"] = "client_associate";
|
||||||
$params["contacts"] = $a->config['admin_email'];
|
$params["contacts"] = $a->config['admin_email'];
|
||||||
$params["application_type"] = "native";
|
$params["application_type"] = "native";
|
||||||
$params["application_name"] = $application_name;
|
$params["application_name"] = $application_name;
|
||||||
$params["logo_url"] = $a->get_baseurl()."/images/friendica-256.png";
|
$params["logo_url"] = $a->get_baseurl()."/images/friendica-256.png";
|
||||||
$params["redirect_uris"] = $a->get_baseurl()."/pumpio/connect";
|
$params["redirect_uris"] = $a->get_baseurl()."/pumpio/connect";
|
||||||
|
|
||||||
logger("pumpio_registerclient: ".$url." parameters ".print_r($params, true), LOGGER_DEBUG);
|
logger("pumpio_registerclient: ".$url." parameters ".print_r($params, true), LOGGER_DEBUG);
|
||||||
|
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
curl_setopt($ch, CURLOPT_HEADER, false);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
|
||||||
curl_setopt($ch, CURLOPT_POST,1);
|
curl_setopt($ch, CURLOPT_POST,1);
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
|
curl_setopt($ch, CURLOPT_POSTFIELDS,$params);
|
||||||
curl_setopt($ch, CURLOPT_USERAGENT, "Friendica");
|
curl_setopt($ch, CURLOPT_USERAGENT, "Friendica");
|
||||||
|
|
||||||
$s = curl_exec($ch);
|
$s = curl_exec($ch);
|
||||||
$curl_info = curl_getinfo($ch);
|
$curl_info = curl_getinfo($ch);
|
||||||
|
|
||||||
if ($curl_info["http_code"] == "200") {
|
if ($curl_info["http_code"] == "200") {
|
||||||
$values = json_decode($s);
|
$values = json_decode($s);
|
||||||
logger("pumpio_registerclient: success ".print_r($values, true), LOGGER_DEBUG);
|
logger("pumpio_registerclient: success ".print_r($values, true), LOGGER_DEBUG);
|
||||||
return($values);
|
return($values);
|
||||||
}
|
}
|
||||||
logger("pumpio_registerclient: failed: ".print_r($curl_info, true), LOGGER_DEBUG);
|
logger("pumpio_registerclient: failed: ".print_r($curl_info, true), LOGGER_DEBUG);
|
||||||
return(false);
|
return(false);
|
||||||
|
|
||||||
|
@ -156,10 +156,10 @@ function pumpio_connect(&$a) {
|
||||||
}
|
}
|
||||||
$success = $client->Finalize($success);
|
$success = $client->Finalize($success);
|
||||||
}
|
}
|
||||||
if($client->exit)
|
if($client->exit)
|
||||||
$o = 'Could not connect to pumpio. Refresh the page or try again later.';
|
$o = 'Could not connect to pumpio. Refresh the page or try again later.';
|
||||||
|
|
||||||
if($success) {
|
if($success) {
|
||||||
logger("pumpio_connect: authenticated");
|
logger("pumpio_connect: authenticated");
|
||||||
$o .= t("You are now authenticated to pumpio.");
|
$o .= t("You are now authenticated to pumpio.");
|
||||||
$o .= '<br /><a href="'.$a->get_baseurl().'/settings/connectors">'.t("return to the connector page").'</a>';
|
$o .= '<br /><a href="'.$a->get_baseurl().'/settings/connectors">'.t("return to the connector page").'</a>';
|
||||||
|
@ -172,118 +172,117 @@ function pumpio_connect(&$a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_jot_nets(&$a,&$b) {
|
function pumpio_jot_nets(&$a,&$b) {
|
||||||
if(! local_user())
|
if(! local_user())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$pumpio_post = get_pconfig(local_user(),'pumpio','post');
|
$pumpio_post = get_pconfig(local_user(),'pumpio','post');
|
||||||
if(intval($pumpio_post) == 1) {
|
if(intval($pumpio_post) == 1) {
|
||||||
$pumpio_defpost = get_pconfig(local_user(),'pumpio','post_by_default');
|
$pumpio_defpost = get_pconfig(local_user(),'pumpio','post_by_default');
|
||||||
$selected = ((intval($pumpio_defpost) == 1) ? ' checked="checked" ' : '');
|
$selected = ((intval($pumpio_defpost) == 1) ? ' checked="checked" ' : '');
|
||||||
$b .= '<div class="profile-jot-net"><input type="checkbox" name="pumpio_enable"' . $selected . ' value="1" /> '
|
$b .= '<div class="profile-jot-net"><input type="checkbox" name="pumpio_enable"' . $selected . ' value="1" /> '
|
||||||
. t('Post to pumpio') . '</div>';
|
. t('Post to pumpio') . '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function pumpio_settings(&$a,&$s) {
|
function pumpio_settings(&$a,&$s) {
|
||||||
|
|
||||||
if(! local_user())
|
if(! local_user())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||||
|
|
||||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/pumpio/pumpio.css' . '" media="all" />' . "\r\n";
|
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/pumpio/pumpio.css' . '" media="all" />' . "\r\n";
|
||||||
|
|
||||||
/* Get the current state of our config variables */
|
/* Get the current state of our config variables */
|
||||||
|
|
||||||
$import_enabled = get_pconfig(local_user(),'pumpio','import');
|
$import_enabled = get_pconfig(local_user(),'pumpio','import');
|
||||||
$import_checked = (($import_enabled) ? ' checked="checked" ' : '');
|
$import_checked = (($import_enabled) ? ' checked="checked" ' : '');
|
||||||
|
|
||||||
$enabled = get_pconfig(local_user(),'pumpio','post');
|
$enabled = get_pconfig(local_user(),'pumpio','post');
|
||||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
$checked = (($enabled) ? ' checked="checked" ' : '');
|
||||||
$css = (($enabled) ? '' : '-disabled');
|
$css = (($enabled) ? '' : '-disabled');
|
||||||
|
|
||||||
$def_enabled = get_pconfig(local_user(),'pumpio','post_by_default');
|
$def_enabled = get_pconfig(local_user(),'pumpio','post_by_default');
|
||||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
||||||
|
|
||||||
$public_enabled = get_pconfig(local_user(),'pumpio','public');
|
$public_enabled = get_pconfig(local_user(),'pumpio','public');
|
||||||
$public_checked = (($public_enabled) ? ' checked="checked" ' : '');
|
$public_checked = (($public_enabled) ? ' checked="checked" ' : '');
|
||||||
|
|
||||||
$mirror_enabled = get_pconfig(local_user(),'pumpio','mirror');
|
$mirror_enabled = get_pconfig(local_user(),'pumpio','mirror');
|
||||||
$mirror_checked = (($mirror_enabled) ? ' checked="checked" ' : '');
|
$mirror_checked = (($mirror_enabled) ? ' checked="checked" ' : '');
|
||||||
|
|
||||||
$servername = get_pconfig(local_user(), "pumpio", "host");
|
$servername = get_pconfig(local_user(), "pumpio", "host");
|
||||||
$username = get_pconfig(local_user(), "pumpio", "user");
|
$username = get_pconfig(local_user(), "pumpio", "user");
|
||||||
|
|
||||||
/* Add some HTML to the existing form */
|
/* Add some HTML to the existing form */
|
||||||
|
|
||||||
$s .= '<span id="settings_pumpio_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
$s .= '<span id="settings_pumpio_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
||||||
$s .= '<img class="connector'.$css.'" src="images/pumpio.png" /><h3 class="connector">'. t('Pump.io Import/Export/Mirror').'</h3>';
|
$s .= '<img class="connector'.$css.'" src="images/pumpio.png" /><h3 class="connector">'. t('Pump.io Import/Export/Mirror').'</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
$s .= '<div id="settings_pumpio_expanded" class="settings-block" style="display: none;">';
|
$s .= '<div id="settings_pumpio_expanded" class="settings-block" style="display: none;">';
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
$s .= '<span class="fakelink" onclick="openClose(\'settings_pumpio_expanded\'); openClose(\'settings_pumpio_inflated\');">';
|
||||||
$s .= '<img class="connector'.$css.'" src="images/pumpio.png" /><h3 class="connector">'. t('Pump.io Import/Export/Mirror').'</h3>';
|
$s .= '<img class="connector'.$css.'" src="images/pumpio.png" /><h3 class="connector">'. t('Pump.io Import/Export/Mirror').'</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
|
|
||||||
$s .= '<div id="pumpio-username-wrapper">';
|
$s .= '<div id="pumpio-username-wrapper">';
|
||||||
$s .= '<label id="pumpio-username-label" for="pumpio-username">'.t('pump.io username (without the servername)').'</label>';
|
$s .= '<label id="pumpio-username-label" for="pumpio-username">'.t('pump.io username (without the servername)').'</label>';
|
||||||
$s .= '<input id="pumpio-username" type="text" name="pumpio_user" value="'.$username.'" />';
|
$s .= '<input id="pumpio-username" type="text" name="pumpio_user" value="'.$username.'" />';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
|
|
||||||
$s .= '<div id="pumpio-servername-wrapper">';
|
$s .= '<div id="pumpio-servername-wrapper">';
|
||||||
$s .= '<label id="pumpio-servername-label" for="pumpio-servername">'.t('pump.io servername (without "http://" or "https://" )').'</label>';
|
$s .= '<label id="pumpio-servername-label" for="pumpio-servername">'.t('pump.io servername (without "http://" or "https://" )').'</label>';
|
||||||
$s .= '<input id="pumpio-servername" type="text" name="pumpio_host" value="'.$servername.'" />';
|
$s .= '<input id="pumpio-servername" type="text" name="pumpio_host" value="'.$servername.'" />';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
|
|
||||||
if (($username != '') AND ($servername != '')) {
|
if (($username != '') AND ($servername != '')) {
|
||||||
|
|
||||||
$oauth_token = get_pconfig(local_user(), "pumpio", "oauth_token");
|
$oauth_token = get_pconfig(local_user(), "pumpio", "oauth_token");
|
||||||
$oauth_token_secret = get_pconfig(local_user(), "pumpio", "oauth_token_secret");
|
$oauth_token_secret = get_pconfig(local_user(), "pumpio", "oauth_token_secret");
|
||||||
|
|
||||||
$s .= '<div id="pumpio-password-wrapper">';
|
$s .= '<div id="pumpio-password-wrapper">';
|
||||||
if (($oauth_token == "") OR ($oauth_token_secret == "")) {
|
if (($oauth_token == "") OR ($oauth_token_secret == "")) {
|
||||||
$s .= '<div id="pumpio-authenticate-wrapper">';
|
$s .= '<div id="pumpio-authenticate-wrapper">';
|
||||||
$s .= '<a href="'.$a->get_baseurl().'/pumpio/connect">'.t("Authenticate your pump.io connection").'</a>';
|
$s .= '<a href="'.$a->get_baseurl().'/pumpio/connect">'.t("Authenticate your pump.io connection").'</a>';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
} else {
|
} else {
|
||||||
$s .= '<div id="pumpio-import-wrapper">';
|
$s .= '<div id="pumpio-import-wrapper">';
|
||||||
$s .= '<label id="pumpio-import-label" for="pumpio-import">' . t('Import the remote timeline') . '</label>';
|
$s .= '<label id="pumpio-import-label" for="pumpio-import">' . t('Import the remote timeline') . '</label>';
|
||||||
$s .= '<input id="pumpio-import" type="checkbox" name="pumpio_import" value="1" ' . $import_checked . '/>';
|
$s .= '<input id="pumpio-import" type="checkbox" name="pumpio_import" value="1" ' . $import_checked . '/>';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
|
|
||||||
$s .= '<div id="pumpio-enable-wrapper">';
|
$s .= '<div id="pumpio-enable-wrapper">';
|
||||||
$s .= '<label id="pumpio-enable-label" for="pumpio-checkbox">' . t('Enable pump.io Post Plugin') . '</label>';
|
$s .= '<label id="pumpio-enable-label" for="pumpio-checkbox">' . t('Enable pump.io Post Plugin') . '</label>';
|
||||||
$s .= '<input id="pumpio-checkbox" type="checkbox" name="pumpio" value="1" ' . $checked . '/>';
|
$s .= '<input id="pumpio-checkbox" type="checkbox" name="pumpio" value="1" ' . $checked . '/>';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
|
|
||||||
$s .= '<div id="pumpio-bydefault-wrapper">';
|
$s .= '<div id="pumpio-bydefault-wrapper">';
|
||||||
$s .= '<label id="pumpio-bydefault-label" for="pumpio-bydefault">' . t('Post to pump.io by default') . '</label>';
|
$s .= '<label id="pumpio-bydefault-label" for="pumpio-bydefault">' . t('Post to pump.io by default') . '</label>';
|
||||||
$s .= '<input id="pumpio-bydefault" type="checkbox" name="pumpio_bydefault" value="1" ' . $def_checked . '/>';
|
$s .= '<input id="pumpio-bydefault" type="checkbox" name="pumpio_bydefault" value="1" ' . $def_checked . '/>';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
|
|
||||||
$s .= '<div id="pumpio-public-wrapper">';
|
$s .= '<div id="pumpio-public-wrapper">';
|
||||||
$s .= '<label id="pumpio-public-label" for="pumpio-public">' . t('Should posts be public?') . '</label>';
|
$s .= '<label id="pumpio-public-label" for="pumpio-public">' . t('Should posts be public?') . '</label>';
|
||||||
$s .= '<input id="pumpio-public" type="checkbox" name="pumpio_public" value="1" ' . $public_checked . '/>';
|
$s .= '<input id="pumpio-public" type="checkbox" name="pumpio_public" value="1" ' . $public_checked . '/>';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
|
|
||||||
$s .= '<div id="pumpio-mirror-wrapper">';
|
$s .= '<div id="pumpio-mirror-wrapper">';
|
||||||
$s .= '<label id="pumpio-mirror-label" for="pumpio-mirror">' . t('Mirror all public posts') . '</label>';
|
$s .= '<label id="pumpio-mirror-label" for="pumpio-mirror">' . t('Mirror all public posts') . '</label>';
|
||||||
$s .= '<input id="pumpio-mirror" type="checkbox" name="pumpio_mirror" value="1" ' . $mirror_checked . '/>';
|
$s .= '<input id="pumpio-mirror" type="checkbox" name="pumpio_mirror" value="1" ' . $mirror_checked . '/>';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
|
|
||||||
|
$s .= '<div id="pumpio-delete-wrapper">';
|
||||||
|
$s .= '<label id="pumpio-delete-label" for="pumpio-delete">' . t('Check to delete this preset') . '</label>';
|
||||||
|
$s .= '<input id="pumpio-delete" type="checkbox" name="pumpio_delete" value="1" />';
|
||||||
|
$s .= '</div><div class="clear"></div>';
|
||||||
|
}
|
||||||
|
|
||||||
$s .= '<div id="pumpio-delete-wrapper">';
|
|
||||||
$s .= '<label id="pumpio-delete-label" for="pumpio-delete">' . t('Check to delete this preset') . '</label>';
|
|
||||||
$s .= '<input id="pumpio-delete" type="checkbox" name="pumpio_delete" value="1" />';
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$s .= '</div><div class="clear"></div>';
|
/* provide a submit button */
|
||||||
}
|
|
||||||
|
|
||||||
/* provide a submit button */
|
|
||||||
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pumpio-submit" name="pumpio-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
|
|
||||||
|
|
||||||
|
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="pumpio-submit" name="pumpio-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -591,28 +590,28 @@ function pumpio_action(&$a, $uid, $uri, $action, $content) {
|
||||||
|
|
||||||
|
|
||||||
function pumpio_cron(&$a,$b) {
|
function pumpio_cron(&$a,$b) {
|
||||||
$last = get_config('pumpio','last_poll');
|
$last = get_config('pumpio','last_poll');
|
||||||
|
|
||||||
$poll_interval = intval(get_config('pumpio','poll_interval'));
|
$poll_interval = intval(get_config('pumpio','poll_interval'));
|
||||||
if(! $poll_interval)
|
if(! $poll_interval)
|
||||||
$poll_interval = PUMPIO_DEFAULT_POLL_INTERVAL;
|
$poll_interval = PUMPIO_DEFAULT_POLL_INTERVAL;
|
||||||
|
|
||||||
if($last) {
|
if($last) {
|
||||||
$next = $last + ($poll_interval * 60);
|
$next = $last + ($poll_interval * 60);
|
||||||
if($next > time()) {
|
if($next > time()) {
|
||||||
logger('pumpio: poll intervall not reached');
|
logger('pumpio: poll intervall not reached');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
logger('pumpio: cron_start');
|
logger('pumpio: cron_start');
|
||||||
|
|
||||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'mirror' AND `v` = '1' ORDER BY RAND() ");
|
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'mirror' AND `v` = '1' ORDER BY RAND() ");
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
foreach($r as $rr) {
|
foreach($r as $rr) {
|
||||||
logger('pumpio: mirroring user '.$rr['uid']);
|
logger('pumpio: mirroring user '.$rr['uid']);
|
||||||
pumpio_fetchtimeline($a, $rr['uid']);
|
pumpio_fetchtimeline($a, $rr['uid']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'import' AND `v` = '1' ORDER BY RAND() ");
|
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'import' AND `v` = '1' ORDER BY RAND() ");
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
|
@ -961,7 +960,7 @@ function pumpio_get_contact($uid, $contact) {
|
||||||
`uri-date` = '%s',
|
`uri-date` = '%s',
|
||||||
`avatar-date` = '%s'
|
`avatar-date` = '%s'
|
||||||
WHERE `id` = %d
|
WHERE `id` = %d
|
||||||
",
|
",
|
||||||
dbesc($photos[0]),
|
dbesc($photos[0]),
|
||||||
dbesc($photos[1]),
|
dbesc($photos[1]),
|
||||||
dbesc($photos[2]),
|
dbesc($photos[2]),
|
||||||
|
@ -983,15 +982,15 @@ function pumpio_get_contact($uid, $contact) {
|
||||||
$photos = import_profile_photo($contact->image->url, $uid, $r[0]['id']);
|
$photos = import_profile_photo($contact->image->url, $uid, $r[0]['id']);
|
||||||
|
|
||||||
q("UPDATE `contact` SET `photo` = '%s',
|
q("UPDATE `contact` SET `photo` = '%s',
|
||||||
`thumb` = '%s',
|
`thumb` = '%s',
|
||||||
`micro` = '%s',
|
`micro` = '%s',
|
||||||
`name-date` = '%s',
|
`name-date` = '%s',
|
||||||
`uri-date` = '%s',
|
`uri-date` = '%s',
|
||||||
`avatar-date` = '%s',
|
`avatar-date` = '%s',
|
||||||
`name` = '%s',
|
`name` = '%s',
|
||||||
`nick` = '%s'
|
`nick` = '%s'
|
||||||
WHERE `id` = %d
|
WHERE `id` = %d
|
||||||
",
|
",
|
||||||
dbesc($photos[0]),
|
dbesc($photos[0]),
|
||||||
dbesc($photos[1]),
|
dbesc($photos[1]),
|
||||||
dbesc($photos[2]),
|
dbesc($photos[2]),
|
||||||
|
@ -1171,9 +1170,9 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
|
||||||
if ($post->verb == "share") {
|
if ($post->verb == "share") {
|
||||||
if (!intval(get_config('system','wall-to-wall_share'))) {
|
if (!intval(get_config('system','wall-to-wall_share'))) {
|
||||||
$postarray['body'] = "[share author='".$post->object->author->displayName.
|
$postarray['body'] = "[share author='".$post->object->author->displayName.
|
||||||
"' profile='".$post->object->author->url.
|
"' profile='".$post->object->author->url.
|
||||||
"' avatar='".$post->object->author->image->url.
|
"' avatar='".$post->object->author->image->url.
|
||||||
"' link='".$post->links->self->href."']".$postarray['body']."[/share]";
|
"' link='".$post->links->self->href."']".$postarray['body']."[/share]";
|
||||||
} else {
|
} else {
|
||||||
// Let shares look like wall-to-wall posts
|
// Let shares look like wall-to-wall posts
|
||||||
$postarray['author-name'] = $post->object->author->displayName;
|
$postarray['author-name'] = $post->object->author->displayName;
|
||||||
|
@ -1259,28 +1258,28 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
|
||||||
|
|
||||||
function pumpio_fetchinbox(&$a, $uid) {
|
function pumpio_fetchinbox(&$a, $uid) {
|
||||||
|
|
||||||
$ckey = get_pconfig($uid, 'pumpio', 'consumer_key');
|
$ckey = get_pconfig($uid, 'pumpio', 'consumer_key');
|
||||||
$csecret = get_pconfig($uid, 'pumpio', 'consumer_secret');
|
$csecret = get_pconfig($uid, 'pumpio', 'consumer_secret');
|
||||||
$otoken = get_pconfig($uid, 'pumpio', 'oauth_token');
|
$otoken = get_pconfig($uid, 'pumpio', 'oauth_token');
|
||||||
$osecret = get_pconfig($uid, 'pumpio', 'oauth_token_secret');
|
$osecret = get_pconfig($uid, 'pumpio', 'oauth_token_secret');
|
||||||
$lastdate = get_pconfig($uid, 'pumpio', 'lastdate');
|
$lastdate = get_pconfig($uid, 'pumpio', 'lastdate');
|
||||||
$hostname = get_pconfig($uid, 'pumpio','host');
|
$hostname = get_pconfig($uid, 'pumpio','host');
|
||||||
$username = get_pconfig($uid, "pumpio", "user");
|
$username = get_pconfig($uid, "pumpio", "user");
|
||||||
|
|
||||||
$own_id = "https://".$hostname."/".$username;
|
$own_id = "https://".$hostname."/".$username;
|
||||||
|
|
||||||
$self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
$self = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1",
|
||||||
intval($uid));
|
intval($uid));
|
||||||
|
|
||||||
$client = new oauth_client_class;
|
$client = new oauth_client_class;
|
||||||
$client->oauth_version = '1.0a';
|
$client->oauth_version = '1.0a';
|
||||||
$client->authorization_header = true;
|
$client->authorization_header = true;
|
||||||
$client->url_parameters = false;
|
$client->url_parameters = false;
|
||||||
|
|
||||||
$client->client_id = $ckey;
|
$client->client_id = $ckey;
|
||||||
$client->client_secret = $csecret;
|
$client->client_secret = $csecret;
|
||||||
$client->access_token = $otoken;
|
$client->access_token = $otoken;
|
||||||
$client->access_token_secret = $osecret;
|
$client->access_token_secret = $osecret;
|
||||||
|
|
||||||
$last_id = get_pconfig($uid,'pumpio','last_id');
|
$last_id = get_pconfig($uid,'pumpio','last_id');
|
||||||
|
|
||||||
|
@ -1289,7 +1288,7 @@ function pumpio_fetchinbox(&$a, $uid) {
|
||||||
if ($last_id != "")
|
if ($last_id != "")
|
||||||
$url .= '?since='.urlencode($last_id);
|
$url .= '?since='.urlencode($last_id);
|
||||||
|
|
||||||
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $user);
|
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $user);
|
||||||
|
|
||||||
if ($user->items) {
|
if ($user->items) {
|
||||||
$posts = array_reverse($user->items);
|
$posts = array_reverse($user->items);
|
||||||
|
@ -1305,31 +1304,31 @@ function pumpio_fetchinbox(&$a, $uid) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function pumpio_getallusers(&$a, $uid) {
|
function pumpio_getallusers(&$a, $uid) {
|
||||||
$ckey = get_pconfig($uid, 'pumpio', 'consumer_key');
|
$ckey = get_pconfig($uid, 'pumpio', 'consumer_key');
|
||||||
$csecret = get_pconfig($uid, 'pumpio', 'consumer_secret');
|
$csecret = get_pconfig($uid, 'pumpio', 'consumer_secret');
|
||||||
$otoken = get_pconfig($uid, 'pumpio', 'oauth_token');
|
$otoken = get_pconfig($uid, 'pumpio', 'oauth_token');
|
||||||
$osecret = get_pconfig($uid, 'pumpio', 'oauth_token_secret');
|
$osecret = get_pconfig($uid, 'pumpio', 'oauth_token_secret');
|
||||||
$hostname = get_pconfig($uid, 'pumpio','host');
|
$hostname = get_pconfig($uid, 'pumpio','host');
|
||||||
$username = get_pconfig($uid, "pumpio", "user");
|
$username = get_pconfig($uid, "pumpio", "user");
|
||||||
|
|
||||||
$client = new oauth_client_class;
|
$client = new oauth_client_class;
|
||||||
$client->oauth_version = '1.0a';
|
$client->oauth_version = '1.0a';
|
||||||
$client->authorization_header = true;
|
$client->authorization_header = true;
|
||||||
$client->url_parameters = false;
|
$client->url_parameters = false;
|
||||||
|
|
||||||
$client->client_id = $ckey;
|
$client->client_id = $ckey;
|
||||||
$client->client_secret = $csecret;
|
$client->client_secret = $csecret;
|
||||||
$client->access_token = $otoken;
|
$client->access_token = $otoken;
|
||||||
$client->access_token_secret = $osecret;
|
$client->access_token_secret = $osecret;
|
||||||
|
|
||||||
$url = 'https://'.$hostname.'/api/user/'.$username.'/following';
|
$url = 'https://'.$hostname.'/api/user/'.$username.'/following';
|
||||||
|
|
||||||
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
|
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
|
||||||
|
|
||||||
if ($users->totalItems > count($users->items)) {
|
if ($users->totalItems > count($users->items)) {
|
||||||
$url = 'https://'.$hostname.'/api/user/'.$username.'/following?count='.$users->totalItems;
|
$url = 'https://'.$hostname.'/api/user/'.$username.'/following?count='.$users->totalItems;
|
||||||
|
|
||||||
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
|
$success = $client->CallAPI($url, 'GET', array(), array('FailOnAccessError'=>true), $users);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($users->items AS $user)
|
foreach ($users->items AS $user)
|
||||||
|
@ -1426,7 +1425,7 @@ function pumpio_getreceiver(&$a, $b) {
|
||||||
|
|
||||||
$public = get_pconfig($b['uid'], "pumpio", "public");
|
$public = get_pconfig($b['uid'], "pumpio", "public");
|
||||||
|
|
||||||
if ($public)
|
if ($public)
|
||||||
$receiver["to"][] = Array(
|
$receiver["to"][] = Array(
|
||||||
"objectType" => "collection",
|
"objectType" => "collection",
|
||||||
"id" => "http://activityschema.org/collection/public");
|
"id" => "http://activityschema.org/collection/public");
|
||||||
|
|
|
@ -171,8 +171,8 @@ function statusnet_settings_post ($a,$post) {
|
||||||
del_pconfig(local_user(), 'statusnet', 'lastid');
|
del_pconfig(local_user(), 'statusnet', 'lastid');
|
||||||
del_pconfig(local_user(), 'statusnet', 'mirror_posts');
|
del_pconfig(local_user(), 'statusnet', 'mirror_posts');
|
||||||
del_pconfig(local_user(), 'statusnet', 'import');
|
del_pconfig(local_user(), 'statusnet', 'import');
|
||||||
del_pconfig(local_user(), 'statusnet', 'create_user');
|
del_pconfig(local_user(), 'statusnet', 'create_user');
|
||||||
del_pconfig(local_user(), 'statusnet', 'own_id');
|
del_pconfig(local_user(), 'statusnet', 'own_id');
|
||||||
} else {
|
} else {
|
||||||
if (isset($_POST['statusnet-preconf-apiurl'])) {
|
if (isset($_POST['statusnet-preconf-apiurl'])) {
|
||||||
/***
|
/***
|
||||||
|
@ -279,9 +279,9 @@ function statusnet_settings(&$a,&$s) {
|
||||||
$mirrorenabled = get_pconfig(local_user(),'statusnet','mirror_posts');
|
$mirrorenabled = get_pconfig(local_user(),'statusnet','mirror_posts');
|
||||||
$mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
|
$mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
|
||||||
$importenabled = get_pconfig(local_user(),'statusnet','import');
|
$importenabled = get_pconfig(local_user(),'statusnet','import');
|
||||||
$importchecked = (($importenabled) ? ' checked="checked" ' : '');
|
$importchecked = (($importenabled) ? ' checked="checked" ' : '');
|
||||||
$create_userenabled = get_pconfig(local_user(),'statusnet','create_user');
|
$create_userenabled = get_pconfig(local_user(),'statusnet','create_user');
|
||||||
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
|
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
|
||||||
|
|
||||||
$css = (($enabled) ? '' : '-disabled');
|
$css = (($enabled) ? '' : '-disabled');
|
||||||
|
|
||||||
|
@ -390,12 +390,12 @@ function statusnet_settings(&$a,&$s) {
|
||||||
$s .= '</div>';
|
$s .= '</div>';
|
||||||
|
|
||||||
$s .= '<label id="statusnet-import-label" for="statusnet-import">'.t('Import the remote timeline').'</label>';
|
$s .= '<label id="statusnet-import-label" for="statusnet-import">'.t('Import the remote timeline').'</label>';
|
||||||
$s .= '<input id="statusnet-import" type="checkbox" name="statusnet-import" value="1" '. $importchecked . '/>';
|
$s .= '<input id="statusnet-import" type="checkbox" name="statusnet-import" value="1" '. $importchecked . '/>';
|
||||||
$s .= '<div class="clear"></div>';
|
$s .= '<div class="clear"></div>';
|
||||||
/*
|
/*
|
||||||
$s .= '<label id="statusnet-create_user-label" for="statusnet-create_user">'.t('Automatically create contacts').'</label>';
|
$s .= '<label id="statusnet-create_user-label" for="statusnet-create_user">'.t('Automatically create contacts').'</label>';
|
||||||
$s .= '<input id="statusnet-create_user" type="checkbox" name="statusnet-create_user" value="1" '. $create_userchecked . '/>';
|
$s .= '<input id="statusnet-create_user" type="checkbox" name="statusnet-create_user" value="1" '. $create_userchecked . '/>';
|
||||||
$s .= '<div class="clear"></div>';
|
$s .= '<div class="clear"></div>';
|
||||||
*/
|
*/
|
||||||
$s .= '<div id="statusnet-disconnect-wrapper">';
|
$s .= '<div id="statusnet-disconnect-wrapper">';
|
||||||
$s .= '<label id="statusnet-disconnect-label" for="statusnet-disconnect">'. t('Clear OAuth configuration') .'</label>';
|
$s .= '<label id="statusnet-disconnect-label" for="statusnet-disconnect">'. t('Clear OAuth configuration') .'</label>';
|
||||||
|
@ -439,20 +439,20 @@ function statusnet_action($a, $uid, $pid, $action) {
|
||||||
|
|
||||||
$connection = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret);
|
$connection = new StatusNetOAuth($api,$ckey,$csecret,$otoken,$osecret);
|
||||||
|
|
||||||
logger("statusnet_action '".$action."' ID: ".$pid, LOGGER_DATA);
|
logger("statusnet_action '".$action."' ID: ".$pid, LOGGER_DATA);
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case "delete":
|
case "delete":
|
||||||
$result = $connection->post("statuses/destroy/".$pid);
|
$result = $connection->post("statuses/destroy/".$pid);
|
||||||
break;
|
break;
|
||||||
case "like":
|
case "like":
|
||||||
$result = $connection->post("favorites/create/".$pid);
|
$result = $connection->post("favorites/create/".$pid);
|
||||||
break;
|
break;
|
||||||
case "unlike":
|
case "unlike":
|
||||||
$result = $connection->post("favorites/destroy/".$pid);
|
$result = $connection->post("favorites/destroy/".$pid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
logger("statusnet_action '".$action."' send, result: " . print_r($result, true), LOGGER_DEBUG);
|
logger("statusnet_action '".$action."' send, result: " . print_r($result, true), LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
||||||
function statusnet_post_hook(&$a,&$b) {
|
function statusnet_post_hook(&$a,&$b) {
|
||||||
|
@ -510,19 +510,19 @@ function statusnet_post_hook(&$a,&$b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($b['verb'] == ACTIVITY_POST) AND $b['deleted'])
|
if (($b['verb'] == ACTIVITY_POST) AND $b['deleted'])
|
||||||
statusnet_action($a, $b["uid"], substr($orig_post["uri"], $hostlength), "delete");
|
statusnet_action($a, $b["uid"], substr($orig_post["uri"], $hostlength), "delete");
|
||||||
|
|
||||||
if($b['verb'] == ACTIVITY_LIKE) {
|
if($b['verb'] == ACTIVITY_LIKE) {
|
||||||
logger("statusnet_post_hook: parameter 2 ".substr($b["thr-parent"], $hostlength), LOGGER_DEBUG);
|
logger("statusnet_post_hook: parameter 2 ".substr($b["thr-parent"], $hostlength), LOGGER_DEBUG);
|
||||||
if ($b['deleted'])
|
if ($b['deleted'])
|
||||||
statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "unlike");
|
statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "unlike");
|
||||||
else
|
else
|
||||||
statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "like");
|
statusnet_action($a, $b["uid"], substr($b["thr-parent"], $hostlength), "like");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($b['deleted'] || ($b['created'] !== $b['edited']))
|
if($b['deleted'] || ($b['created'] !== $b['edited']))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if posts comes from statusnet don't send it back
|
// if posts comes from statusnet don't send it back
|
||||||
if($b['app'] == "StatusNet")
|
if($b['app'] == "StatusNet")
|
||||||
|
@ -700,12 +700,12 @@ function statusnet_cron($a,$b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
|
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'statusnet' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
foreach($r as $rr) {
|
foreach($r as $rr) {
|
||||||
logger('statusnet: importing timeline from user '.$rr['uid']);
|
logger('statusnet: importing timeline from user '.$rr['uid']);
|
||||||
statusnet_fetchhometimeline($a, $rr["uid"]);
|
statusnet_fetchhometimeline($a, $rr["uid"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('statusnet: cron_end');
|
logger('statusnet: cron_end');
|
||||||
|
|
||||||
|
@ -1429,7 +1429,7 @@ function statusnet_convertmsg($a, $body, $no_tags = false) {
|
||||||
$expanded_url = original_url($match[1]);
|
$expanded_url = original_url($match[1]);
|
||||||
|
|
||||||
$oembed_data = oembed_fetch_url($expanded_url, true);
|
$oembed_data = oembed_fetch_url($expanded_url, true);
|
||||||
print_r($oembed_data);
|
|
||||||
if ($type == "")
|
if ($type == "")
|
||||||
$type = $oembed_data->type;
|
$type = $oembed_data->type;
|
||||||
if ($oembed_data->type == "video") {
|
if ($oembed_data->type == "video") {
|
||||||
|
|
200
tumblr/tumblr.php
Executable file → Normal file
200
tumblr/tumblr.php
Executable file → Normal file
|
@ -12,19 +12,19 @@ require_once('library/OAuth1.php');
|
||||||
require_once('addon/tumblr/tumblroauth/tumblroauth.php');
|
require_once('addon/tumblr/tumblroauth/tumblroauth.php');
|
||||||
|
|
||||||
function tumblr_install() {
|
function tumblr_install() {
|
||||||
register_hook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
|
register_hook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
|
||||||
register_hook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
|
register_hook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
|
||||||
register_hook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
|
register_hook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
|
||||||
register_hook('connector_settings', 'addon/tumblr/tumblr.php', 'tumblr_settings');
|
register_hook('connector_settings', 'addon/tumblr/tumblr.php', 'tumblr_settings');
|
||||||
register_hook('connector_settings_post', 'addon/tumblr/tumblr.php', 'tumblr_settings_post');
|
register_hook('connector_settings_post', 'addon/tumblr/tumblr.php', 'tumblr_settings_post');
|
||||||
|
|
||||||
}
|
}
|
||||||
function tumblr_uninstall() {
|
function tumblr_uninstall() {
|
||||||
unregister_hook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
|
unregister_hook('post_local', 'addon/tumblr/tumblr.php', 'tumblr_post_local');
|
||||||
unregister_hook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
|
unregister_hook('notifier_normal', 'addon/tumblr/tumblr.php', 'tumblr_send');
|
||||||
unregister_hook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
|
unregister_hook('jot_networks', 'addon/tumblr/tumblr.php', 'tumblr_jot_nets');
|
||||||
unregister_hook('connector_settings', 'addon/tumblr/tumblr.php', 'tumblr_settings');
|
unregister_hook('connector_settings', 'addon/tumblr/tumblr.php', 'tumblr_settings');
|
||||||
unregister_hook('connector_settings_post', 'addon/tumblr/tumblr.php', 'tumblr_settings_post');
|
unregister_hook('connector_settings_post', 'addon/tumblr/tumblr.php', 'tumblr_settings_post');
|
||||||
}
|
}
|
||||||
|
|
||||||
function tumblr_module() {}
|
function tumblr_module() {}
|
||||||
|
@ -85,22 +85,22 @@ function tumblr_connect($a) {
|
||||||
|
|
||||||
// Check the HTTP Code. It should be a 200 (OK), if it's anything else then something didn't work.
|
// Check the HTTP Code. It should be a 200 (OK), if it's anything else then something didn't work.
|
||||||
switch ($tum_oauth->http_code) {
|
switch ($tum_oauth->http_code) {
|
||||||
case 200:
|
case 200:
|
||||||
// Ask Tumblr to give us a special address to their login page
|
// Ask Tumblr to give us a special address to their login page
|
||||||
$url = $tum_oauth->getAuthorizeURL($token);
|
$url = $tum_oauth->getAuthorizeURL($token);
|
||||||
|
|
||||||
// Redirect the user to the login URL given to us by Tumblr
|
// Redirect the user to the login URL given to us by Tumblr
|
||||||
header('Location: ' . $url);
|
header('Location: ' . $url);
|
||||||
|
|
||||||
// That's it for our side. The user is sent to a Tumblr Login page and
|
// That's it for our side. The user is sent to a Tumblr Login page and
|
||||||
// asked to authroize our app. After that, Tumblr sends the user back to
|
// asked to authroize our app. After that, Tumblr sends the user back to
|
||||||
// our Callback URL (callback.php) along with some information we need to get
|
// our Callback URL (callback.php) along with some information we need to get
|
||||||
// an access token.
|
// an access token.
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Give an error message
|
// Give an error message
|
||||||
$o = 'Could not connect to Tumblr. Refresh the page or try again later.';
|
$o = 'Could not connect to Tumblr. Refresh the page or try again later.';
|
||||||
}
|
}
|
||||||
return($o);
|
return($o);
|
||||||
}
|
}
|
||||||
|
@ -133,9 +133,9 @@ function tumblr_callback($a) {
|
||||||
|
|
||||||
// Make sure nothing went wrong.
|
// Make sure nothing went wrong.
|
||||||
if (200 == $tum_oauth->http_code) {
|
if (200 == $tum_oauth->http_code) {
|
||||||
// good to go
|
// good to go
|
||||||
} else {
|
} else {
|
||||||
return('Unable to authenticate');
|
return('Unable to authenticate');
|
||||||
}
|
}
|
||||||
|
|
||||||
// What's next? Now that we have an Access Token and Secret, we can make an API call.
|
// What's next? Now that we have an Access Token and Secret, we can make an API call.
|
||||||
|
@ -148,96 +148,96 @@ function tumblr_callback($a) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function tumblr_jot_nets(&$a,&$b) {
|
function tumblr_jot_nets(&$a,&$b) {
|
||||||
if(! local_user())
|
if(! local_user())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$tmbl_post = get_pconfig(local_user(),'tumblr','post');
|
$tmbl_post = get_pconfig(local_user(),'tumblr','post');
|
||||||
if(intval($tmbl_post) == 1) {
|
if(intval($tmbl_post) == 1) {
|
||||||
$tmbl_defpost = get_pconfig(local_user(),'tumblr','post_by_default');
|
$tmbl_defpost = get_pconfig(local_user(),'tumblr','post_by_default');
|
||||||
$selected = ((intval($tmbl_defpost) == 1) ? ' checked="checked" ' : '');
|
$selected = ((intval($tmbl_defpost) == 1) ? ' checked="checked" ' : '');
|
||||||
$b .= '<div class="profile-jot-net"><input type="checkbox" name="tumblr_enable"' . $selected . ' value="1" /> '
|
$b .= '<div class="profile-jot-net"><input type="checkbox" name="tumblr_enable"' . $selected . ' value="1" /> '
|
||||||
. t('Post to Tumblr') . '</div>';
|
. t('Post to Tumblr') . '</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function tumblr_settings(&$a,&$s) {
|
function tumblr_settings(&$a,&$s) {
|
||||||
|
|
||||||
if(! local_user())
|
if(! local_user())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Add our stylesheet to the page so we can make our settings look nice */
|
/* Add our stylesheet to the page so we can make our settings look nice */
|
||||||
|
|
||||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/tumblr/tumblr.css' . '" media="all" />' . "\r\n";
|
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/tumblr/tumblr.css' . '" media="all" />' . "\r\n";
|
||||||
|
|
||||||
/* Get the current state of our config variables */
|
/* Get the current state of our config variables */
|
||||||
|
|
||||||
$enabled = get_pconfig(local_user(),'tumblr','post');
|
$enabled = get_pconfig(local_user(),'tumblr','post');
|
||||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
$checked = (($enabled) ? ' checked="checked" ' : '');
|
||||||
$css = (($enabled) ? '' : '-disabled');
|
$css = (($enabled) ? '' : '-disabled');
|
||||||
|
|
||||||
$def_enabled = get_pconfig(local_user(),'tumblr','post_by_default');
|
$def_enabled = get_pconfig(local_user(),'tumblr','post_by_default');
|
||||||
|
|
||||||
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
$def_checked = (($def_enabled) ? ' checked="checked" ' : '');
|
||||||
|
|
||||||
/* Add some HTML to the existing form */
|
/* Add some HTML to the existing form */
|
||||||
|
|
||||||
$s .= '<span id="settings_tumblr_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
$s .= '<span id="settings_tumblr_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
||||||
$s .= '<img class="connector'.$css.'" src="images/tumblr.png" /><h3 class="connector">'. t('Tumblr Export').'</h3>';
|
$s .= '<img class="connector'.$css.'" src="images/tumblr.png" /><h3 class="connector">'. t('Tumblr Export').'</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
$s .= '<div id="settings_tumblr_expanded" class="settings-block" style="display: none;">';
|
$s .= '<div id="settings_tumblr_expanded" class="settings-block" style="display: none;">';
|
||||||
$s .= '<span class="fakelink" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
$s .= '<span class="fakelink" onclick="openClose(\'settings_tumblr_expanded\'); openClose(\'settings_tumblr_inflated\');">';
|
||||||
$s .= '<img class="connector'.$css.'" src="images/tumblr.png" /><h3 class="connector">'. t('Tumblr Export').'</h3>';
|
$s .= '<img class="connector'.$css.'" src="images/tumblr.png" /><h3 class="connector">'. t('Tumblr Export').'</h3>';
|
||||||
$s .= '</span>';
|
$s .= '</span>';
|
||||||
|
|
||||||
$s .= '<div id="tumblr-username-wrapper">';
|
$s .= '<div id="tumblr-username-wrapper">';
|
||||||
$s .= '<a href="'.$a->get_baseurl().'/tumblr/connect">'.t("(Re-)Authenticate your tumblr page").'</a>';
|
$s .= '<a href="'.$a->get_baseurl().'/tumblr/connect">'.t("(Re-)Authenticate your tumblr page").'</a>';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
|
|
||||||
$s .= '<div id="tumblr-enable-wrapper">';
|
$s .= '<div id="tumblr-enable-wrapper">';
|
||||||
$s .= '<label id="tumblr-enable-label" for="tumblr-checkbox">' . t('Enable Tumblr Post Plugin') . '</label>';
|
$s .= '<label id="tumblr-enable-label" for="tumblr-checkbox">' . t('Enable Tumblr Post Plugin') . '</label>';
|
||||||
$s .= '<input id="tumblr-checkbox" type="checkbox" name="tumblr" value="1" ' . $checked . '/>';
|
$s .= '<input id="tumblr-checkbox" type="checkbox" name="tumblr" value="1" ' . $checked . '/>';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
|
|
||||||
$s .= '<div id="tumblr-bydefault-wrapper">';
|
$s .= '<div id="tumblr-bydefault-wrapper">';
|
||||||
$s .= '<label id="tumblr-bydefault-label" for="tumblr-bydefault">' . t('Post to Tumblr by default') . '</label>';
|
$s .= '<label id="tumblr-bydefault-label" for="tumblr-bydefault">' . t('Post to Tumblr by default') . '</label>';
|
||||||
$s .= '<input id="tumblr-bydefault" type="checkbox" name="tumblr_bydefault" value="1" ' . $def_checked . '/>';
|
$s .= '<input id="tumblr-bydefault" type="checkbox" name="tumblr_bydefault" value="1" ' . $def_checked . '/>';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
|
|
||||||
$oauth_token = get_pconfig(local_user(), "tumblr", "oauth_token");
|
$oauth_token = get_pconfig(local_user(), "tumblr", "oauth_token");
|
||||||
$oauth_token_secret = get_pconfig(local_user(), "tumblr", "oauth_token_secret");
|
$oauth_token_secret = get_pconfig(local_user(), "tumblr", "oauth_token_secret");
|
||||||
|
|
||||||
$s .= '<div id="tumblr-page-wrapper">';
|
$s .= '<div id="tumblr-page-wrapper">';
|
||||||
if (($oauth_token != "") and ($oauth_token_secret != "")) {
|
if (($oauth_token != "") and ($oauth_token_secret != "")) {
|
||||||
|
|
||||||
$page = get_pconfig(local_user(),'tumblr','page');
|
$page = get_pconfig(local_user(),'tumblr','page');
|
||||||
$consumer_key = get_config('tumblr','consumer_key');
|
$consumer_key = get_config('tumblr','consumer_key');
|
||||||
$consumer_secret = get_config('tumblr','consumer_secret');
|
$consumer_secret = get_config('tumblr','consumer_secret');
|
||||||
|
|
||||||
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
|
$tum_oauth = new TumblrOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);
|
||||||
|
|
||||||
$userinfo = $tum_oauth->get('user/info');
|
$userinfo = $tum_oauth->get('user/info');
|
||||||
|
|
||||||
$blogs = array();
|
$blogs = array();
|
||||||
|
|
||||||
$s .= '<label id="tumblr-page-label" for="tumblr-page">' . t('Post to page:') . '</label>';
|
$s .= '<label id="tumblr-page-label" for="tumblr-page">' . t('Post to page:') . '</label>';
|
||||||
$s .= '<select name="tumblr_page" id="tumblr-page">';
|
$s .= '<select name="tumblr_page" id="tumblr-page">';
|
||||||
foreach($userinfo->response->user->blogs as $blog) {
|
foreach($userinfo->response->user->blogs as $blog) {
|
||||||
$blogurl = substr(str_replace(array("http://", "https://"), array("", ""), $blog->url), 0, -1);
|
$blogurl = substr(str_replace(array("http://", "https://"), array("", ""), $blog->url), 0, -1);
|
||||||
if ($page == $blogurl)
|
if ($page == $blogurl)
|
||||||
$s .= "<option value='".$blogurl."' selected>".$blogurl."</option>";
|
$s .= "<option value='".$blogurl."' selected>".$blogurl."</option>";
|
||||||
else
|
else
|
||||||
$s .= "<option value='".$blogurl."'>".$blogurl."</option>";
|
$s .= "<option value='".$blogurl."'>".$blogurl."</option>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$s .= "</select>";
|
$s .= "</select>";
|
||||||
} else
|
} else
|
||||||
$s .= t("You are not authenticated to tumblr");
|
$s .= t("You are not authenticated to tumblr");
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
|
|
||||||
/* provide a submit button */
|
/* provide a submit button */
|
||||||
|
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="tumblr-submit" name="tumblr-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
|
$s .= '<div class="settings-submit-wrapper" ><input type="submit" id="tumblr-submit" name="tumblr-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div></div>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,19 +267,19 @@ function tumblr_post_local(&$a,&$b) {
|
||||||
if($b['private'] || $b['parent'])
|
if($b['private'] || $b['parent'])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$tmbl_post = intval(get_pconfig(local_user(),'tumblr','post'));
|
$tmbl_post = intval(get_pconfig(local_user(),'tumblr','post'));
|
||||||
|
|
||||||
$tmbl_enable = (($tmbl_post && x($_REQUEST,'tumblr_enable')) ? intval($_REQUEST['tumblr_enable']) : 0);
|
$tmbl_enable = (($tmbl_post && x($_REQUEST,'tumblr_enable')) ? intval($_REQUEST['tumblr_enable']) : 0);
|
||||||
|
|
||||||
if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'tumblr','post_by_default')))
|
if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'tumblr','post_by_default')))
|
||||||
$tmbl_enable = 1;
|
$tmbl_enable = 1;
|
||||||
|
|
||||||
if(! $tmbl_enable)
|
if(! $tmbl_enable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(strlen($b['postopts']))
|
if(strlen($b['postopts']))
|
||||||
$b['postopts'] .= ',';
|
$b['postopts'] .= ',';
|
||||||
$b['postopts'] .= 'tumblr';
|
$b['postopts'] .= 'tumblr';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -287,14 +287,14 @@ function tumblr_post_local(&$a,&$b) {
|
||||||
|
|
||||||
function tumblr_send(&$a,&$b) {
|
function tumblr_send(&$a,&$b) {
|
||||||
|
|
||||||
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
|
if($b['deleted'] || $b['private'] || ($b['created'] !== $b['edited']))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(! strstr($b['postopts'],'tumblr'))
|
if(! strstr($b['postopts'],'tumblr'))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if($b['parent'] != $b['id'])
|
if($b['parent'] != $b['id'])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
$oauth_token = get_pconfig($b['uid'], "tumblr", "oauth_token");
|
$oauth_token = get_pconfig($b['uid'], "tumblr", "oauth_token");
|
||||||
$oauth_token_secret = get_pconfig($b['uid'], "tumblr", "oauth_token_secret");
|
$oauth_token_secret = get_pconfig($b['uid'], "tumblr", "oauth_token_secret");
|
||||||
|
|
253
twitter/twitter.php
Executable file → Normal file
253
twitter/twitter.php
Executable file → Normal file
|
@ -64,7 +64,7 @@ define('TWITTER_DEFAULT_POLL_INTERVAL', 5); // given in minutes
|
||||||
|
|
||||||
function twitter_install() {
|
function twitter_install() {
|
||||||
// we need some hooks, for the configuration and for sending tweets
|
// we need some hooks, for the configuration and for sending tweets
|
||||||
register_hook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
|
register_hook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
|
||||||
register_hook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
|
register_hook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
|
||||||
register_hook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
|
register_hook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
|
||||||
register_hook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook');
|
register_hook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook');
|
||||||
|
@ -72,12 +72,13 @@ function twitter_install() {
|
||||||
register_hook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
|
register_hook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
|
||||||
register_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
|
register_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
|
||||||
register_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
|
register_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
|
||||||
|
register_hook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
|
||||||
logger("installed twitter");
|
logger("installed twitter");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function twitter_uninstall() {
|
function twitter_uninstall() {
|
||||||
unregister_hook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
|
unregister_hook('connector_settings', 'addon/twitter/twitter.php', 'twitter_settings');
|
||||||
unregister_hook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
|
unregister_hook('connector_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
|
||||||
unregister_hook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
|
unregister_hook('post_local', 'addon/twitter/twitter.php', 'twitter_post_local');
|
||||||
unregister_hook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook');
|
unregister_hook('notifier_normal', 'addon/twitter/twitter.php', 'twitter_post_hook');
|
||||||
|
@ -85,10 +86,11 @@ function twitter_uninstall() {
|
||||||
unregister_hook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
|
unregister_hook('cron', 'addon/twitter/twitter.php', 'twitter_cron');
|
||||||
unregister_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
|
unregister_hook('queue_predeliver', 'addon/twitter/twitter.php', 'twitter_queue_hook');
|
||||||
unregister_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
|
unregister_hook('follow', 'addon/twitter/twitter.php', 'twitter_follow');
|
||||||
|
unregister_hook('expire', 'addon/twitter/twitter.php', 'twitter_expire');
|
||||||
|
|
||||||
// old setting - remove only
|
// old setting - remove only
|
||||||
unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
|
unregister_hook('post_local_end', 'addon/twitter/twitter.php', 'twitter_post_hook');
|
||||||
unregister_hook('plugin_settings', 'addon/twitter/twitter.php', 'twitter_settings');
|
unregister_hook('plugin_settings', 'addon/twitter/twitter.php', 'twitter_settings');
|
||||||
unregister_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
|
unregister_hook('plugin_settings_post', 'addon/twitter/twitter.php', 'twitter_settings_post');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -159,10 +161,10 @@ function twitter_settings_post ($a,$post) {
|
||||||
*/
|
*/
|
||||||
del_pconfig(local_user(), 'twitter', 'consumerkey');
|
del_pconfig(local_user(), 'twitter', 'consumerkey');
|
||||||
del_pconfig(local_user(), 'twitter', 'consumersecret');
|
del_pconfig(local_user(), 'twitter', 'consumersecret');
|
||||||
del_pconfig(local_user(), 'twitter', 'oauthtoken');
|
del_pconfig(local_user(), 'twitter', 'oauthtoken');
|
||||||
del_pconfig(local_user(), 'twitter', 'oauthsecret');
|
del_pconfig(local_user(), 'twitter', 'oauthsecret');
|
||||||
del_pconfig(local_user(), 'twitter', 'post');
|
del_pconfig(local_user(), 'twitter', 'post');
|
||||||
del_pconfig(local_user(), 'twitter', 'post_by_default');
|
del_pconfig(local_user(), 'twitter', 'post_by_default');
|
||||||
del_pconfig(local_user(), 'twitter', 'lastid');
|
del_pconfig(local_user(), 'twitter', 'lastid');
|
||||||
del_pconfig(local_user(), 'twitter', 'mirror_posts');
|
del_pconfig(local_user(), 'twitter', 'mirror_posts');
|
||||||
del_pconfig(local_user(), 'twitter', 'import');
|
del_pconfig(local_user(), 'twitter', 'import');
|
||||||
|
@ -181,30 +183,30 @@ function twitter_settings_post ($a,$post) {
|
||||||
$connection = new TwitterOAuth($ckey, $csecret, $_POST['twitter-token'], $_POST['twitter-token2']);
|
$connection = new TwitterOAuth($ckey, $csecret, $_POST['twitter-token'], $_POST['twitter-token2']);
|
||||||
$token = $connection->getAccessToken( $_POST['twitter-pin'] );
|
$token = $connection->getAccessToken( $_POST['twitter-pin'] );
|
||||||
// ok, now that we have the Access Token, save them in the user config
|
// ok, now that we have the Access Token, save them in the user config
|
||||||
set_pconfig(local_user(),'twitter', 'oauthtoken', $token['oauth_token']);
|
set_pconfig(local_user(),'twitter', 'oauthtoken', $token['oauth_token']);
|
||||||
set_pconfig(local_user(),'twitter', 'oauthsecret', $token['oauth_token_secret']);
|
set_pconfig(local_user(),'twitter', 'oauthsecret', $token['oauth_token_secret']);
|
||||||
set_pconfig(local_user(),'twitter', 'post', 1);
|
set_pconfig(local_user(),'twitter', 'post', 1);
|
||||||
// reload the Addon Settings page, if we don't do it see Bug #42
|
// reload the Addon Settings page, if we don't do it see Bug #42
|
||||||
goaway($a->get_baseurl().'/settings/connectors');
|
goaway($a->get_baseurl().'/settings/connectors');
|
||||||
} else {
|
} else {
|
||||||
// if no PIN is supplied in the POST variables, the user has changed the setting
|
// if no PIN is supplied in the POST variables, the user has changed the setting
|
||||||
// to post a tweet for every new __public__ posting to the wall
|
// to post a tweet for every new __public__ posting to the wall
|
||||||
set_pconfig(local_user(),'twitter','post',intval($_POST['twitter-enable']));
|
set_pconfig(local_user(),'twitter','post',intval($_POST['twitter-enable']));
|
||||||
set_pconfig(local_user(),'twitter','post_by_default',intval($_POST['twitter-default']));
|
set_pconfig(local_user(),'twitter','post_by_default',intval($_POST['twitter-default']));
|
||||||
set_pconfig(local_user(), 'twitter', 'mirror_posts', intval($_POST['twitter-mirror']));
|
set_pconfig(local_user(), 'twitter', 'mirror_posts', intval($_POST['twitter-mirror']));
|
||||||
set_pconfig(local_user(), 'twitter', 'import', intval($_POST['twitter-import']));
|
set_pconfig(local_user(), 'twitter', 'import', intval($_POST['twitter-import']));
|
||||||
set_pconfig(local_user(), 'twitter', 'create_user', intval($_POST['twitter-create_user']));
|
set_pconfig(local_user(), 'twitter', 'create_user', intval($_POST['twitter-create_user']));
|
||||||
|
|
||||||
if (!intval($_POST['twitter-mirror']))
|
if (!intval($_POST['twitter-mirror']))
|
||||||
del_pconfig(local_user(),'twitter','lastid');
|
del_pconfig(local_user(),'twitter','lastid');
|
||||||
|
|
||||||
info(t('Twitter settings updated.') . EOL);
|
info(t('Twitter settings updated.') . EOL);
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
function twitter_settings(&$a,&$s) {
|
function twitter_settings(&$a,&$s) {
|
||||||
if(! local_user())
|
if(! local_user())
|
||||||
return;
|
return;
|
||||||
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/twitter/twitter.css' . '" media="all" />' . "\r\n";
|
$a->page['htmlhead'] .= '<link rel="stylesheet" type="text/css" href="' . $a->get_baseurl() . '/addon/twitter/twitter.css' . '" media="all" />' . "\r\n";
|
||||||
/***
|
/***
|
||||||
* 1) Check that we have global consumer key & secret
|
* 1) Check that we have global consumer key & secret
|
||||||
* 2) If no OAuthtoken & stuff is present, generate button to get some
|
* 2) If no OAuthtoken & stuff is present, generate button to get some
|
||||||
|
@ -214,16 +216,16 @@ function twitter_settings(&$a,&$s) {
|
||||||
$csecret = get_config('twitter', 'consumersecret' );
|
$csecret = get_config('twitter', 'consumersecret' );
|
||||||
$otoken = get_pconfig(local_user(), 'twitter', 'oauthtoken' );
|
$otoken = get_pconfig(local_user(), 'twitter', 'oauthtoken' );
|
||||||
$osecret = get_pconfig(local_user(), 'twitter', 'oauthsecret' );
|
$osecret = get_pconfig(local_user(), 'twitter', 'oauthsecret' );
|
||||||
$enabled = get_pconfig(local_user(), 'twitter', 'post');
|
$enabled = get_pconfig(local_user(), 'twitter', 'post');
|
||||||
$checked = (($enabled) ? ' checked="checked" ' : '');
|
$checked = (($enabled) ? ' checked="checked" ' : '');
|
||||||
$defenabled = get_pconfig(local_user(),'twitter','post_by_default');
|
$defenabled = get_pconfig(local_user(),'twitter','post_by_default');
|
||||||
$defchecked = (($defenabled) ? ' checked="checked" ' : '');
|
$defchecked = (($defenabled) ? ' checked="checked" ' : '');
|
||||||
$mirrorenabled = get_pconfig(local_user(),'twitter','mirror_posts');
|
$mirrorenabled = get_pconfig(local_user(),'twitter','mirror_posts');
|
||||||
$mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
|
$mirrorchecked = (($mirrorenabled) ? ' checked="checked" ' : '');
|
||||||
$importenabled = get_pconfig(local_user(),'twitter','import');
|
$importenabled = get_pconfig(local_user(),'twitter','import');
|
||||||
$importchecked = (($importenabled) ? ' checked="checked" ' : '');
|
$importchecked = (($importenabled) ? ' checked="checked" ' : '');
|
||||||
$create_userenabled = get_pconfig(local_user(),'twitter','create_user');
|
$create_userenabled = get_pconfig(local_user(),'twitter','create_user');
|
||||||
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
|
$create_userchecked = (($create_userenabled) ? ' checked="checked" ' : '');
|
||||||
|
|
||||||
$css = (($enabled) ? '' : '-disabled');
|
$css = (($enabled) ? '' : '-disabled');
|
||||||
|
|
||||||
|
@ -252,7 +254,7 @@ function twitter_settings(&$a,&$s) {
|
||||||
* which the user can request a PIN to connect the account to a
|
* which the user can request a PIN to connect the account to a
|
||||||
* account at Twitter.
|
* account at Twitter.
|
||||||
*/
|
*/
|
||||||
require_once('library/twitteroauth.php');
|
require_once('library/twitteroauth.php');
|
||||||
$connection = new TwitterOAuth($ckey, $csecret);
|
$connection = new TwitterOAuth($ckey, $csecret);
|
||||||
$request_token = $connection->getRequestToken();
|
$request_token = $connection->getRequestToken();
|
||||||
$token = $request_token['oauth_token'];
|
$token = $request_token['oauth_token'];
|
||||||
|
@ -266,50 +268,50 @@ function twitter_settings(&$a,&$s) {
|
||||||
$s .= '<input id="twitter-pin" type="text" name="twitter-pin" />';
|
$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="'.$token.'" />';
|
||||||
$s .= '<input id="twitter-token2" type="hidden" name="twitter-token2" value="'.$request_token['oauth_token_secret'].'" />';
|
$s .= '<input id="twitter-token2" type="hidden" name="twitter-token2" value="'.$request_token['oauth_token_secret'].'" />';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
|
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
|
||||||
} else {
|
} else {
|
||||||
/***
|
/***
|
||||||
* we have an OAuth key / secret pair for the user
|
* we have an OAuth key / secret pair for the user
|
||||||
* so let's give a chance to disable the postings to Twitter
|
* so let's give a chance to disable the postings to Twitter
|
||||||
*/
|
*/
|
||||||
require_once('library/twitteroauth.php');
|
require_once('library/twitteroauth.php');
|
||||||
$connection = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
|
$connection = new TwitterOAuth($ckey,$csecret,$otoken,$osecret);
|
||||||
$details = $connection->get('account/verify_credentials');
|
$details = $connection->get('account/verify_credentials');
|
||||||
$s .= '<div id="twitter-info" ><img id="twitter-avatar" src="'.$details->profile_image_url.'" /><p id="twitter-info-block">'. t('Currently connected to: ') .'<a href="https://twitter.com/'.$details->screen_name.'" target="_twitter">'.$details->screen_name.'</a><br /><em>'.$details->description.'</em></p></div>';
|
$s .= '<div id="twitter-info" ><img id="twitter-avatar" src="'.$details->profile_image_url.'" /><p id="twitter-info-block">'. t('Currently connected to: ') .'<a href="https://twitter.com/'.$details->screen_name.'" target="_twitter">'.$details->screen_name.'</a><br /><em>'.$details->description.'</em></p></div>';
|
||||||
$s .= '<p>'. t('If enabled all your <strong>public</strong> postings can be posted to the associated Twitter account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.') .'</p>';
|
$s .= '<p>'. t('If enabled all your <strong>public</strong> postings can be posted to the associated Twitter account. You can choose to do so by default (here) or for every posting separately in the posting options when writing the entry.') .'</p>';
|
||||||
if ($a->user['hidewall']) {
|
if ($a->user['hidewall']) {
|
||||||
$s .= '<p>'. t('<strong>Note</strong>: Due your privacy settings (<em>Hide your profile details from unknown viewers?</em>) the link potentially included in public postings relayed to Twitter will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') .'</p>';
|
$s .= '<p>'. t('<strong>Note</strong>: Due your privacy settings (<em>Hide your profile details from unknown viewers?</em>) the link potentially included in public postings relayed to Twitter will lead the visitor to a blank page informing the visitor that the access to your profile has been restricted.') .'</p>';
|
||||||
}
|
}
|
||||||
$s .= '<div id="twitter-enable-wrapper">';
|
$s .= '<div id="twitter-enable-wrapper">';
|
||||||
$s .= '<label id="twitter-enable-label" for="twitter-checkbox">'. t('Allow posting to Twitter'). '</label>';
|
$s .= '<label id="twitter-enable-label" for="twitter-checkbox">'. t('Allow posting to Twitter'). '</label>';
|
||||||
$s .= '<input id="twitter-checkbox" type="checkbox" name="twitter-enable" value="1" ' . $checked . '/>';
|
$s .= '<input id="twitter-checkbox" type="checkbox" name="twitter-enable" value="1" ' . $checked . '/>';
|
||||||
$s .= '<div class="clear"></div>';
|
$s .= '<div class="clear"></div>';
|
||||||
$s .= '<label id="twitter-default-label" for="twitter-default">'. t('Send public postings to Twitter by default') .'</label>';
|
$s .= '<label id="twitter-default-label" for="twitter-default">'. t('Send public postings to Twitter by default') .'</label>';
|
||||||
$s .= '<input id="twitter-default" type="checkbox" name="twitter-default" value="1" ' . $defchecked . '/>';
|
$s .= '<input id="twitter-default" type="checkbox" name="twitter-default" value="1" ' . $defchecked . '/>';
|
||||||
$s .= '<div class="clear"></div>';
|
$s .= '<div class="clear"></div>';
|
||||||
|
|
||||||
$s .= '<label id="twitter-mirror-label" for="twitter-mirror">'.t('Mirror all posts from twitter that are no replies').'</label>';
|
$s .= '<label id="twitter-mirror-label" for="twitter-mirror">'.t('Mirror all posts from twitter that are no replies').'</label>';
|
||||||
$s .= '<input id="twitter-mirror" type="checkbox" name="twitter-mirror" value="1" '. $mirrorchecked . '/>';
|
$s .= '<input id="twitter-mirror" type="checkbox" name="twitter-mirror" value="1" '. $mirrorchecked . '/>';
|
||||||
$s .= '<div class="clear"></div>';
|
$s .= '<div class="clear"></div>';
|
||||||
$s .= '</div>';
|
$s .= '</div>';
|
||||||
|
|
||||||
$s .= '<label id="twitter-import-label" for="twitter-import">'.t('Import the remote timeline').'</label>';
|
$s .= '<label id="twitter-import-label" for="twitter-import">'.t('Import the remote timeline').'</label>';
|
||||||
$s .= '<input id="twitter-import" type="checkbox" name="twitter-import" value="1" '. $importchecked . '/>';
|
$s .= '<input id="twitter-import" type="checkbox" name="twitter-import" value="1" '. $importchecked . '/>';
|
||||||
$s .= '<div class="clear"></div>';
|
$s .= '<div class="clear"></div>';
|
||||||
|
|
||||||
$s .= '<label id="twitter-create_user-label" for="twitter-create_user">'.t('Automatically create contacts').'</label>';
|
$s .= '<label id="twitter-create_user-label" for="twitter-create_user">'.t('Automatically create contacts').'</label>';
|
||||||
$s .= '<input id="twitter-create_user" type="checkbox" name="twitter-create_user" value="1" '. $create_userchecked . '/>';
|
$s .= '<input id="twitter-create_user" type="checkbox" name="twitter-create_user" value="1" '. $create_userchecked . '/>';
|
||||||
$s .= '<div class="clear"></div>';
|
$s .= '<div class="clear"></div>';
|
||||||
|
|
||||||
$s .= '<div id="twitter-disconnect-wrapper">';
|
$s .= '<div id="twitter-disconnect-wrapper">';
|
||||||
$s .= '<label id="twitter-disconnect-label" for="twitter-disconnect">'. t('Clear OAuth configuration') .'</label>';
|
$s .= '<label id="twitter-disconnect-label" for="twitter-disconnect">'. t('Clear OAuth configuration') .'</label>';
|
||||||
$s .= '<input id="twitter-disconnect" type="checkbox" name="twitter-disconnect" value="1" />';
|
$s .= '<input id="twitter-disconnect" type="checkbox" name="twitter-disconnect" value="1" />';
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
|
$s .= '<div class="settings-submit-wrapper" ><input type="submit" name="twitter-submit" class="settings-submit" value="' . t('Save Settings') . '" /></div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$s .= '</div><div class="clear"></div>';
|
$s .= '</div><div class="clear"></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -327,12 +329,12 @@ function twitter_post_local(&$a,&$b) {
|
||||||
if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'twitter','post_by_default')))
|
if($_REQUEST['api_source'] && intval(get_pconfig(local_user(),'twitter','post_by_default')))
|
||||||
$twitter_enable = 1;
|
$twitter_enable = 1;
|
||||||
|
|
||||||
if(! $twitter_enable)
|
if(! $twitter_enable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(strlen($b['postopts']))
|
if(strlen($b['postopts']))
|
||||||
$b['postopts'] .= ',';
|
$b['postopts'] .= ',';
|
||||||
$b['postopts'] .= 'twitter';
|
$b['postopts'] .= 'twitter';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,29 +385,31 @@ function twitter_post_hook(&$a,&$b) {
|
||||||
if($b['parent'] != $b['id']) {
|
if($b['parent'] != $b['id']) {
|
||||||
logger("twitter_post_hook: parameter ".print_r($b, true), LOGGER_DATA);
|
logger("twitter_post_hook: parameter ".print_r($b, true), LOGGER_DATA);
|
||||||
|
|
||||||
// Looking if its a reply to a twitter post
|
// Looking if its a reply to a twitter post
|
||||||
if ((substr($b["parent-uri"], 0, 9) != "twitter::") AND (substr($b["extid"], 0, 9) != "twitter::") AND (substr($b["thr-parent"], 0, 9) != "twitter::")) {
|
if ((substr($b["parent-uri"], 0, 9) != "twitter::") AND (substr($b["extid"], 0, 9) != "twitter::") AND (substr($b["thr-parent"], 0, 9) != "twitter::")) {
|
||||||
logger("twitter_post_hook: no twitter post ".$b["parent"]);
|
logger("twitter_post_hook: no twitter post ".$b["parent"]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT * FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1",
|
$r = q("SELECT * FROM item WHERE item.uri = '%s' AND item.uid = %d LIMIT 1",
|
||||||
dbesc($b["thr-parent"]),
|
dbesc($b["thr-parent"]),
|
||||||
intval($b["uid"]));
|
intval($b["uid"]));
|
||||||
|
|
||||||
if(!count($r)) {
|
if(!count($r)) {
|
||||||
logger("twitter_post_hook: no parent found ".$b["thr-parent"]);
|
logger("twitter_post_hook: no parent found ".$b["thr-parent"]);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
$iscomment = true;
|
$iscomment = true;
|
||||||
$orig_post = $r[0];
|
$orig_post = $r[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
$nickname = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
|
|
||||||
$nickname = "@[url=".$orig_post["author-link"]."]".$nickname."[/url]";
|
|
||||||
|
|
||||||
logger("twitter_post_hook: comparing ".$nickname." with ".$b["body"], LOGGER_DEBUG);
|
$nicknameplain = preg_replace("=https?://twitter.com/(.*)=ism", "$1", $orig_post["author-link"]);
|
||||||
if (strpos($b["body"], $nickname) === false)
|
$nickname = "@[url=".$orig_post["author-link"]."]".$nicknameplain."[/url]";
|
||||||
|
$nicknameplain = "@".$nicknameplain;
|
||||||
|
|
||||||
|
logger("twitter_post_hook: comparing ".$nickname." and ".$nicknameplain." with ".$b["body"], LOGGER_DEBUG);
|
||||||
|
if ((strpos($b["body"], $nickname) === false) AND (strpos($b["body"], $nicknameplain) === false))
|
||||||
$b["body"] = $nickname." ".$b["body"];
|
$b["body"] = $nickname." ".$b["body"];
|
||||||
|
|
||||||
logger("twitter_post_hook: parent found ".print_r($orig_post, true), LOGGER_DATA);
|
logger("twitter_post_hook: parent found ".print_r($orig_post, true), LOGGER_DATA);
|
||||||
|
@ -426,10 +430,10 @@ function twitter_post_hook(&$a,&$b) {
|
||||||
else
|
else
|
||||||
twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "like");
|
twitter_action($a, $b["uid"], substr($b["thr-parent"], 9), "like");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($b['deleted'] || ($b['created'] !== $b['edited']))
|
if($b['deleted'] || ($b['created'] !== $b['edited']))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// if post comes from twitter don't send it back
|
// if post comes from twitter don't send it back
|
||||||
if($b['app'] == "Twitter")
|
if($b['app'] == "Twitter")
|
||||||
|
@ -482,7 +486,7 @@ function twitter_post_hook(&$a,&$b) {
|
||||||
// so we are using a new library for twitter
|
// so we are using a new library for twitter
|
||||||
// To-Do:
|
// To-Do:
|
||||||
// Switching completely to this library with all functions
|
// Switching completely to this library with all functions
|
||||||
require_once("addon/twitter/codebird.php");
|
require_once("addon/twitter/codebird.php");
|
||||||
|
|
||||||
$cb = \Codebird\Codebird::getInstance();
|
$cb = \Codebird\Codebird::getInstance();
|
||||||
$cb->setConsumerKey($ckey, $csecret);
|
$cb->setConsumerKey($ckey, $csecret);
|
||||||
|
@ -552,7 +556,7 @@ function twitter_post_hook(&$a,&$b) {
|
||||||
function twitter_plugin_admin_post(&$a){
|
function twitter_plugin_admin_post(&$a){
|
||||||
$consumerkey = ((x($_POST,'consumerkey')) ? notags(trim($_POST['consumerkey'])) : '');
|
$consumerkey = ((x($_POST,'consumerkey')) ? notags(trim($_POST['consumerkey'])) : '');
|
||||||
$consumersecret = ((x($_POST,'consumersecret')) ? notags(trim($_POST['consumersecret'])): '');
|
$consumersecret = ((x($_POST,'consumersecret')) ? notags(trim($_POST['consumersecret'])): '');
|
||||||
$applicationname = ((x($_POST, 'applicationname')) ? notags(trim($_POST['applicationname'])):'');
|
$applicationname = ((x($_POST, 'applicationname')) ? notags(trim($_POST['applicationname'])):'');
|
||||||
set_config('twitter','consumerkey',$consumerkey);
|
set_config('twitter','consumerkey',$consumerkey);
|
||||||
set_config('twitter','consumersecret',$consumersecret);
|
set_config('twitter','consumersecret',$consumersecret);
|
||||||
set_config('twitter','application_name',$applicationname);
|
set_config('twitter','application_name',$applicationname);
|
||||||
|
@ -565,8 +569,8 @@ function twitter_plugin_admin(&$a, &$o){
|
||||||
'$submit' => t('Save Settings'),
|
'$submit' => t('Save Settings'),
|
||||||
// name, label, value, help, [extra values]
|
// name, label, value, help, [extra values]
|
||||||
'$consumerkey' => array('consumerkey', t('Consumer key'), get_config('twitter', 'consumerkey' ), ''),
|
'$consumerkey' => array('consumerkey', t('Consumer key'), get_config('twitter', 'consumerkey' ), ''),
|
||||||
'$consumersecret' => array('consumersecret', t('Consumer secret'), get_config('twitter', 'consumersecret' ), ''),
|
'$consumersecret' => array('consumersecret', t('Consumer secret'), get_config('twitter', 'consumersecret' ), ''),
|
||||||
'$applicationname' => array('applicationname', t('Name of the Twitter Application'), get_config('twitter','application_name'),t('set this to avoid mirroring postings from ~friendica back to ~friendica'))
|
'$applicationname' => array('applicationname', t('Name of the Twitter Application'), get_config('twitter','application_name'),t('set this to avoid mirroring postings from ~friendica back to ~friendica'))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,27 +607,51 @@ function twitter_cron($a,$b) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// To-Do
|
// To-Do
|
||||||
// check for new contacts once a day
|
// check for new contacts once a day
|
||||||
$last_contact_check = get_pconfig($rr['uid'],'pumpio','contact_check');
|
$last_contact_check = get_pconfig($rr['uid'],'pumpio','contact_check');
|
||||||
if($last_contact_check)
|
if($last_contact_check)
|
||||||
$next_contact_check = $last_contact_check + 86400;
|
$next_contact_check = $last_contact_check + 86400;
|
||||||
else
|
else
|
||||||
$next_contact_check = 0;
|
$next_contact_check = 0;
|
||||||
|
|
||||||
if($next_contact_check <= time()) {
|
if($next_contact_check <= time()) {
|
||||||
pumpio_getallusers($a, $rr["uid"]);
|
pumpio_getallusers($a, $rr["uid"]);
|
||||||
set_pconfig($rr['uid'],'pumpio','contact_check',time());
|
set_pconfig($rr['uid'],'pumpio','contact_check',time());
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger('twitter: cron_end');
|
logger('twitter: cron_end');
|
||||||
|
|
||||||
set_config('twitter','last_poll', time());
|
set_config('twitter','last_poll', time());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function twitter_expire($a,$b) {
|
||||||
|
|
||||||
|
$days = get_config('twitter', 'expire');
|
||||||
|
|
||||||
|
if ($days == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$r = q("DELETE FROM `item` WHERE `deleted` AND `network` = '%s'", dbesc(NETWORK_TWITTER));
|
||||||
|
|
||||||
|
require_once("include/items.php");
|
||||||
|
|
||||||
|
logger('twitter_expire: expire_start');
|
||||||
|
|
||||||
|
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'twitter' AND `k` = 'import' AND `v` = '1' ORDER BY RAND()");
|
||||||
|
if(count($r)) {
|
||||||
|
foreach($r as $rr) {
|
||||||
|
logger('twitter_expire: user '.$rr['uid']);
|
||||||
|
item_expire($rr['uid'], $days, NETWORK_TWITTER, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger('twitter_expire: expire_end');
|
||||||
|
}
|
||||||
|
|
||||||
function twitter_fetchtimeline($a, $uid) {
|
function twitter_fetchtimeline($a, $uid) {
|
||||||
$ckey = get_config('twitter', 'consumerkey');
|
$ckey = get_config('twitter', 'consumerkey');
|
||||||
$csecret = get_config('twitter', 'consumersecret');
|
$csecret = get_config('twitter', 'consumersecret');
|
||||||
|
@ -658,7 +686,7 @@ function twitter_fetchtimeline($a, $uid) {
|
||||||
|
|
||||||
$posts = array_reverse($items);
|
$posts = array_reverse($items);
|
||||||
|
|
||||||
if (count($posts)) {
|
if (count($posts)) {
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
if ($post->id_str > $lastid)
|
if ($post->id_str > $lastid)
|
||||||
$lastid = $post->id_str;
|
$lastid = $post->id_str;
|
||||||
|
@ -741,8 +769,8 @@ function twitter_fetchtimeline($a, $uid) {
|
||||||
// require_once('mod/item.php');
|
// require_once('mod/item.php');
|
||||||
|
|
||||||
item_post($a);
|
item_post($a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set_pconfig($uid, 'twitter', 'lastid', $lastid);
|
set_pconfig($uid, 'twitter', 'lastid', $lastid);
|
||||||
}
|
}
|
||||||
|
@ -816,7 +844,7 @@ function twitter_fetch_contact($uid, $contact, $create_user) {
|
||||||
|
|
||||||
// Check if the unique contact is existing
|
// Check if the unique contact is existing
|
||||||
// To-Do: only update once a while
|
// To-Do: only update once a while
|
||||||
$r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
|
$r = q("SELECT id FROM unique_contacts WHERE url='%s' LIMIT 1",
|
||||||
dbesc(normalise_link("https://twitter.com/".$contact->screen_name)));
|
dbesc(normalise_link("https://twitter.com/".$contact->screen_name)));
|
||||||
|
|
||||||
if (count($r) == 0)
|
if (count($r) == 0)
|
||||||
|
@ -1088,16 +1116,16 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
|
||||||
}
|
}
|
||||||
|
|
||||||
// it seems as if the entities aren't always covering all mentions. So the rest will be checked here
|
// it seems as if the entities aren't always covering all mentions. So the rest will be checked here
|
||||||
$tags = get_tags($body);
|
$tags = get_tags($body);
|
||||||
|
|
||||||
if(count($tags)) {
|
if(count($tags)) {
|
||||||
foreach($tags as $tag) {
|
foreach($tags as $tag) {
|
||||||
if (strstr(trim($tag), " "))
|
if (strstr(trim($tag), " "))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(strpos($tag,'#') === 0) {
|
if(strpos($tag,'#') === 0) {
|
||||||
if(strpos($tag,'[url='))
|
if(strpos($tag,'[url='))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// don't link tags that are already embedded in links
|
// don't link tags that are already embedded in links
|
||||||
|
|
||||||
|
@ -1112,8 +1140,8 @@ function twitter_expand_entities($a, $body, $item, $no_tags = false, $dontinclud
|
||||||
$tags_arr["#".$basetag] = $url;
|
$tags_arr["#".$basetag] = $url;
|
||||||
continue;
|
continue;
|
||||||
} elseif(strpos($tag,'@') === 0) {
|
} elseif(strpos($tag,'@') === 0) {
|
||||||
if(strpos($tag,'[url='))
|
if(strpos($tag,'[url='))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$basetag = substr($tag,1);
|
$basetag = substr($tag,1);
|
||||||
$url = '@[url=https://twitter.com/'.rawurlencode($basetag).']'.$basetag.'[/url]';
|
$url = '@[url=https://twitter.com/'.rawurlencode($basetag).']'.$basetag.'[/url]';
|
||||||
|
@ -1432,7 +1460,7 @@ function twitter_fetchhometimeline($a, $uid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$posts = array_reverse($items);
|
$posts = array_reverse($items);
|
||||||
|
|
||||||
logger("twitter_fetchhometimeline: Fetching timeline for user ".$uid." ".sizeof($posts)." items", LOGGER_DEBUG);
|
logger("twitter_fetchhometimeline: Fetching timeline for user ".$uid." ".sizeof($posts)." items", LOGGER_DEBUG);
|
||||||
|
|
||||||
|
@ -1475,7 +1503,7 @@ function twitter_fetchhometimeline($a, $uid) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$posts = array_reverse($items);
|
$posts = array_reverse($items);
|
||||||
|
|
||||||
logger("twitter_fetchhometimeline: Fetching mentions for user ".$uid." ".sizeof($posts)." items", LOGGER_DEBUG);
|
logger("twitter_fetchhometimeline: Fetching mentions for user ".$uid." ".sizeof($posts)." items", LOGGER_DEBUG);
|
||||||
|
|
||||||
|
@ -1509,19 +1537,19 @@ function twitter_fetchhometimeline($a, $uid) {
|
||||||
require_once('include/enotify.php');
|
require_once('include/enotify.php');
|
||||||
notification(array(
|
notification(array(
|
||||||
'type' => NOTIFY_TAGSELF,
|
'type' => NOTIFY_TAGSELF,
|
||||||
'notify_flags' => $u[0]['notify-flags'],
|
'notify_flags' => $u[0]['notify-flags'],
|
||||||
'language' => $u[0]['language'],
|
'language' => $u[0]['language'],
|
||||||
'to_name' => $u[0]['username'],
|
'to_name' => $u[0]['username'],
|
||||||
'to_email' => $u[0]['email'],
|
'to_email' => $u[0]['email'],
|
||||||
'uid' => $u[0]['uid'],
|
'uid' => $u[0]['uid'],
|
||||||
'item' => $postarray,
|
'item' => $postarray,
|
||||||
'link' => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item,
|
'link' => $a->get_baseurl() . '/display/' . $u[0]['nickname'] . '/' . $item,
|
||||||
'source_name' => $postarray['author-name'],
|
'source_name' => $postarray['author-name'],
|
||||||
'source_link' => $postarray['author-link'],
|
'source_link' => $postarray['author-link'],
|
||||||
'source_photo' => $postarray['author-avatar'],
|
'source_photo' => $postarray['author-avatar'],
|
||||||
'verb' => ACTIVITY_TAG,
|
'verb' => ACTIVITY_TAG,
|
||||||
'otype' => 'item'
|
'otype' => 'item'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1552,8 +1580,8 @@ function twitter_fetch_own_contact($a, $uid) {
|
||||||
$contact_id = twitter_fetch_contact($uid, $user, true);
|
$contact_id = twitter_fetch_contact($uid, $user, true);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `alias` = '%s' LIMIT 1",
|
||||||
intval($uid), dbesc("twitter::".$own_id));
|
intval($uid), dbesc("twitter::".$own_id));
|
||||||
if(count($r))
|
if(count($r))
|
||||||
$contact_id = $r[0]["id"];
|
$contact_id = $r[0]["id"];
|
||||||
else
|
else
|
||||||
|
@ -1610,5 +1638,4 @@ function twitter_is_retweet($a, $uid, $body) {
|
||||||
|
|
||||||
return(!isset($result->errors));
|
return(!isset($result->errors));
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue