Merge pull request #157 from annando/master

Bidirectional twitter sync - and some small fixes
pull/158/head
tobiasd 2013-10-20 05:55:45 -07:00
commit 14676e5b0d
7 changed files with 1041 additions and 35 deletions

View File

@ -202,7 +202,7 @@ function appnetpost_original_url($url, $depth=1) {
curl_setopt($ch, CURLOPT_NOBODY, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
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);
$curl_info = @curl_getinfo($ch);

View File

@ -304,6 +304,9 @@ function fromgplus_handleattachments($item, $displaytext) {
function fromgplus_fetch($a, $uid) {
$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');
$key = get_config('fromgplus','key');
@ -330,6 +333,15 @@ function fromgplus_fetch($a, $uid) {
$lastdate = strtotime($item->published);
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) {
case "note":
$post = fromgplus_html2bbcode($item->object->content);
@ -343,9 +355,7 @@ function fromgplus_fetch($a, $uid) {
else
$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);
break;
@ -353,7 +363,7 @@ function fromgplus_fetch($a, $uid) {
case "activity":
$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).
"' profile='".$item->object->actor->url.
"' avatar='".$item->object->actor->image->url.
@ -379,9 +389,7 @@ function fromgplus_fetch($a, $uid) {
else
$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);
break;
}

View File

@ -220,7 +220,7 @@ function gpluspost_original_url($url, $depth=1) {
curl_setopt($ch, CURLOPT_NOBODY, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
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);
$curl_info = @curl_getinfo($ch);

View File

@ -484,7 +484,7 @@ function pumpio_send(&$a,&$b) {
logger('pumpio_send '.$username.': success '.$post_id);
if($post_id AND $iscomment) {
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),
intval($b['id'])
);
@ -925,7 +925,7 @@ function pumpio_get_contact($uid, $contact) {
`name-date` = '%s',
`uri-date` = '%s',
`avatar-date` = '%s'
WHERE `id` = %d LIMIT 1
WHERE `id` = %d
",
dbesc($photos[0]),
dbesc($photos[1]),
@ -952,8 +952,10 @@ function pumpio_get_contact($uid, $contact) {
`micro` = '%s',
`name-date` = '%s',
`uri-date` = '%s',
`avatar-date` = '%s'
WHERE `id` = %d LIMIT 1
`avatar-date` = '%s',
`name` = '%s',
`nick` = '%s'
WHERE `id` = %d
",
dbesc($photos[0]),
dbesc($photos[1]),
@ -961,6 +963,8 @@ function pumpio_get_contact($uid, $contact) {
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc($contact->displayName),
dbesc($contact->preferredUsername),
intval($r[0]['id'])
);
}
@ -1129,10 +1133,17 @@ function pumpio_dopost(&$a, $client, $uid, $self, $post, $own_id, $threadcomplet
}
if ($post->verb == "share") {
$postarray['body'] = "[share author='".$post->object->author->displayName.
"' profile='".$post->object->author->url.
"' avatar='".$post->object->author->image->url.
"' link='".$post->links->self->href."']".$postarray['body']."[/share]";
if (!intval(get_config('system','wall-to-wall_share'))) {
$postarray['body'] = "[share author='".$post->object->author->displayName.
"' profile='".$post->object->author->url.
"' avatar='".$post->object->author->image->url.
"' 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']) == "")
@ -1350,7 +1361,7 @@ function pumpio_queue_hook(&$a,&$b) {
logger('pumpio_queue: send '.$username.': success '.$post_id);
if($post_id AND $iscomment) {
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),
intval($z['item'])
);

View File

@ -548,7 +548,7 @@ function statusnet_shortenmsg($b, $max_char) {
$msglink = $b["plink"];
// 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"=>""));
// If the message is short enough and contains a picture then post the picture as well

View File

@ -24,6 +24,8 @@
#twitter-enable-label,
#twitter-shortening-label,
#twitter-mirror-label,
#twitter-import-label,
#twitter-create_user-label,
#twitter-pin-label {
float: left;
width: 250px;

File diff suppressed because it is too large Load Diff