mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-11-28 21:53:15 +00:00
Merge pull request #157 from annando/master
Bidirectional twitter sync - and some small fixes
This commit is contained in:
commit
14676e5b0d
7 changed files with 1041 additions and 35 deletions
|
@ -202,7 +202,7 @@ function appnetpost_original_url($url, $depth=1) {
|
||||||
curl_setopt($ch, CURLOPT_NOBODY, 0);
|
curl_setopt($ch, CURLOPT_NOBODY, 0);
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
|
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch,CURLOPT_USERAGENT,'Opera/9.64(Windows NT 5.1; U; de) Presto/2.1.1');
|
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0');
|
||||||
|
|
||||||
$header = curl_exec($ch);
|
$header = curl_exec($ch);
|
||||||
$curl_info = @curl_getinfo($ch);
|
$curl_info = @curl_getinfo($ch);
|
||||||
|
|
|
@ -304,6 +304,9 @@ function fromgplus_handleattachments($item, $displaytext) {
|
||||||
function fromgplus_fetch($a, $uid) {
|
function fromgplus_fetch($a, $uid) {
|
||||||
$maxfetch = 20;
|
$maxfetch = 20;
|
||||||
|
|
||||||
|
// Special blank to identify postings from the googleplus connector
|
||||||
|
$blank = html_entity_decode(" ", ENT_QUOTES, 'UTF-8');
|
||||||
|
|
||||||
$account = get_pconfig($uid,'fromgplus','account');
|
$account = get_pconfig($uid,'fromgplus','account');
|
||||||
$key = get_config('fromgplus','key');
|
$key = get_config('fromgplus','key');
|
||||||
|
|
||||||
|
@ -330,6 +333,15 @@ function fromgplus_fetch($a, $uid) {
|
||||||
$lastdate = strtotime($item->published);
|
$lastdate = strtotime($item->published);
|
||||||
|
|
||||||
if ($item->access->description == "Public")
|
if ($item->access->description == "Public")
|
||||||
|
|
||||||
|
// Loop prevention - ignore postings from HootSuite
|
||||||
|
if ($item->provider->title == "HootSuite")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Loop prevention through the special blank from the googleplus connector
|
||||||
|
if (strstr($item->object->content, $blank))
|
||||||
|
continue;
|
||||||
|
|
||||||
switch($item->object->objectType) {
|
switch($item->object->objectType) {
|
||||||
case "note":
|
case "note":
|
||||||
$post = fromgplus_html2bbcode($item->object->content);
|
$post = fromgplus_html2bbcode($item->object->content);
|
||||||
|
@ -343,8 +355,6 @@ function fromgplus_fetch($a, $uid) {
|
||||||
else
|
else
|
||||||
$location = "";
|
$location = "";
|
||||||
|
|
||||||
// Loop prevention - should be made better
|
|
||||||
if ($item->provider->title != "HootSuite")
|
|
||||||
fromgplus_post($a, $uid, "Google+", $post, $location);
|
fromgplus_post($a, $uid, "Google+", $post, $location);
|
||||||
//fromgplus_post($a, $uid, $item->provider->title, $post, $location);
|
//fromgplus_post($a, $uid, $item->provider->title, $post, $location);
|
||||||
|
|
||||||
|
@ -353,7 +363,7 @@ function fromgplus_fetch($a, $uid) {
|
||||||
case "activity":
|
case "activity":
|
||||||
$post = fromgplus_html2bbcode($item->annotation)."\n";
|
$post = fromgplus_html2bbcode($item->annotation)."\n";
|
||||||
|
|
||||||
if (intval(get_config('system','new_share'))) {
|
if (!intval(get_config('system','old_share'))) {
|
||||||
$post .= "[share author='".str_replace("'", "'",$item->object->actor->displayName).
|
$post .= "[share author='".str_replace("'", "'",$item->object->actor->displayName).
|
||||||
"' profile='".$item->object->actor->url.
|
"' profile='".$item->object->actor->url.
|
||||||
"' avatar='".$item->object->actor->image->url.
|
"' avatar='".$item->object->actor->image->url.
|
||||||
|
@ -379,8 +389,6 @@ function fromgplus_fetch($a, $uid) {
|
||||||
else
|
else
|
||||||
$location = "";
|
$location = "";
|
||||||
|
|
||||||
// Loop prevention - should be made better
|
|
||||||
if ($item->provider->title != "HootSuite")
|
|
||||||
fromgplus_post($a, $uid, "Google+", $post, $location);
|
fromgplus_post($a, $uid, "Google+", $post, $location);
|
||||||
//fromgplus_post($a, $uid, $item->provider->title, $post, $location);
|
//fromgplus_post($a, $uid, $item->provider->title, $post, $location);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -220,7 +220,7 @@ function gpluspost_original_url($url, $depth=1) {
|
||||||
curl_setopt($ch, CURLOPT_NOBODY, 0);
|
curl_setopt($ch, CURLOPT_NOBODY, 0);
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
|
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($ch,CURLOPT_USERAGENT,'Opera/9.64(Windows NT 5.1; U; de) Presto/2.1.1');
|
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0');
|
||||||
|
|
||||||
$header = curl_exec($ch);
|
$header = curl_exec($ch);
|
||||||
$curl_info = @curl_getinfo($ch);
|
$curl_info = @curl_getinfo($ch);
|
||||||
|
|
|
@ -484,7 +484,7 @@ function pumpio_send(&$a,&$b) {
|
||||||
logger('pumpio_send '.$username.': success '.$post_id);
|
logger('pumpio_send '.$username.': success '.$post_id);
|
||||||
if($post_id AND $iscomment) {
|
if($post_id AND $iscomment) {
|
||||||
logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$b['id']);
|
logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$b['id']);
|
||||||
q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d LIMIT 1",
|
q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
|
||||||
dbesc($post_id),
|
dbesc($post_id),
|
||||||
intval($b['id'])
|
intval($b['id'])
|
||||||
);
|
);
|
||||||
|
@ -925,7 +925,7 @@ function pumpio_get_contact($uid, $contact) {
|
||||||
`name-date` = '%s',
|
`name-date` = '%s',
|
||||||
`uri-date` = '%s',
|
`uri-date` = '%s',
|
||||||
`avatar-date` = '%s'
|
`avatar-date` = '%s'
|
||||||
WHERE `id` = %d LIMIT 1
|
WHERE `id` = %d
|
||||||
",
|
",
|
||||||
dbesc($photos[0]),
|
dbesc($photos[0]),
|
||||||
dbesc($photos[1]),
|
dbesc($photos[1]),
|
||||||
|
@ -952,8 +952,10 @@ function pumpio_get_contact($uid, $contact) {
|
||||||
`micro` = '%s',
|
`micro` = '%s',
|
||||||
`name-date` = '%s',
|
`name-date` = '%s',
|
||||||
`uri-date` = '%s',
|
`uri-date` = '%s',
|
||||||
`avatar-date` = '%s'
|
`avatar-date` = '%s',
|
||||||
WHERE `id` = %d LIMIT 1
|
`name` = '%s',
|
||||||
|
`nick` = '%s'
|
||||||
|
WHERE `id` = %d
|
||||||
",
|
",
|
||||||
dbesc($photos[0]),
|
dbesc($photos[0]),
|
||||||
dbesc($photos[1]),
|
dbesc($photos[1]),
|
||||||
|
@ -961,6 +963,8 @@ function pumpio_get_contact($uid, $contact) {
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
|
dbesc($contact->displayName),
|
||||||
|
dbesc($contact->preferredUsername),
|
||||||
intval($r[0]['id'])
|
intval($r[0]['id'])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1129,10 +1133,17 @@ 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'))) {
|
||||||
$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 {
|
||||||
|
// Let shares look like wall-to-wall posts
|
||||||
|
$postarray['author-name'] = $post->object->author->displayName;
|
||||||
|
$postarray['author-link'] = $post->object->author->url;
|
||||||
|
$postarray['author-avatar'] = $post->object->author->image->url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trim($postarray['body']) == "")
|
if (trim($postarray['body']) == "")
|
||||||
|
@ -1350,7 +1361,7 @@ function pumpio_queue_hook(&$a,&$b) {
|
||||||
logger('pumpio_queue: send '.$username.': success '.$post_id);
|
logger('pumpio_queue: send '.$username.': success '.$post_id);
|
||||||
if($post_id AND $iscomment) {
|
if($post_id AND $iscomment) {
|
||||||
logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$z['item']);
|
logger('pumpio_send '.$username.': Update extid '.$post_id." for post id ".$z['item']);
|
||||||
q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d LIMIT 1",
|
q("UPDATE `item` SET `extid` = '%s' WHERE `id` = %d",
|
||||||
dbesc($post_id),
|
dbesc($post_id),
|
||||||
intval($z['item'])
|
intval($z['item'])
|
||||||
);
|
);
|
||||||
|
|
|
@ -548,7 +548,7 @@ function statusnet_shortenmsg($b, $max_char) {
|
||||||
$msglink = $b["plink"];
|
$msglink = $b["plink"];
|
||||||
|
|
||||||
// If the message is short enough then don't modify it. (if the link exists in the original message)
|
// If the message is short enough then don't modify it. (if the link exists in the original message)
|
||||||
if ((strlen(trim($origmsg)) <= $max_char) AND (strpos($origmsg, $msglink) OR ($msglink == "")))
|
if ((strlen(trim($origmsg)) <= $max_char) AND (($msglink == "") OR strpos($origmsg, $msglink)))
|
||||||
return(array("msg"=>trim($origmsg), "image"=>""));
|
return(array("msg"=>trim($origmsg), "image"=>""));
|
||||||
|
|
||||||
// If the message is short enough and contains a picture then post the picture as well
|
// If the message is short enough and contains a picture then post the picture as well
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#twitter-enable-label,
|
#twitter-enable-label,
|
||||||
#twitter-shortening-label,
|
#twitter-shortening-label,
|
||||||
#twitter-mirror-label,
|
#twitter-mirror-label,
|
||||||
|
#twitter-import-label,
|
||||||
|
#twitter-create_user-label,
|
||||||
#twitter-pin-label {
|
#twitter-pin-label {
|
||||||
float: left;
|
float: left;
|
||||||
width: 250px;
|
width: 250px;
|
||||||
|
|
1005
twitter/twitter.php
1005
twitter/twitter.php
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue