<?php
/**
* Name: Buffer Post Connector
- * Description: Post to Buffer
- * Version: 0.1 alpha
+ * Description: Post to Buffer (Linkedin, App.net, Google+, Facebook, Twitter)
+ * Version: 0.2
* Author: Michael Vogel <http://pirati.ca/profile/heluecht>
*/
require('addon/buffer/bufferapp.php');
'$client_secret' => array('client_secret', t('Client Secret'), get_config('buffer', 'client_secret' ), ''),
));
}
+function buffer_plugin_admin_post(&$a){
+ $client_id = ((x($_POST,'client_id')) ? notags(trim($_POST['client_id'])) : '');
+ $client_secret = ((x($_POST,'client_secret')) ? notags(trim($_POST['client_secret'])): '');
+ set_config('buffer','client_id',$client_id);
+ set_config('buffer','client_secret',$client_secret);
+ info( t('Settings updated.'). EOL );
+}
function buffer_connect(&$a) {
set_pconfig(local_user(),'buffer','post',false);
set_pconfig(local_user(),'buffer','post_by_default',false);
} else {
- // filtering the username if it is filled wrong
- $user = $_POST['buffer_user'];
- if (strstr($user, "@")) {
- $pos = strpos($user, "@");
- if ($pos > 0)
- $user = substr($user, 0, $pos);
- }
-
- // Filtering the hostname if someone is entering it with "http"
- $host = $_POST['buffer_host'];
- $host = trim($host);
- $host = str_replace(array("https://", "http://"), array("", ""), $host);
-
set_pconfig(local_user(),'buffer','post',intval($_POST['buffer']));
set_pconfig(local_user(),'buffer','post_by_default',intval($_POST['buffer_bydefault']));
-
- //header("Location: ".$a->get_baseurl()."/buffer/connect");
}
}
}
$post["preview"] = $a->get_baseurl() . "/privacy_image_cache/".privacy_image_cache_cachename($post["preview"]);
}
+ //if ($profile->service == "twitter") {
if ($includedlinks) {
if (isset($post["url"]))
$post["url"] = short_link($post["url"]);
// Seems like a bug to me
// Buffer doesn't add links to Twitter and App.net (but pictures)
- if ($includedlinks AND isset($post["url"]))
+ //if ($includedlinks AND isset($post["url"]))
+ if (($profile->service == "twitter") AND isset($post["url"]))
+ $post["text"] .= " ".$post["url"];
+ elseif (($profile->service == "appdotnet") AND isset($post["url"]) AND isset($post["title"])) {
+ $post["title"] = shortenmsg($post["title"], 90);
+ $post["text"] = shortenmsg($post["text"], $limit - (24 + strlen($post["title"])));
+ $post["text"] .= "\n[".$post["title"]."](".$post["url"].")";
+ } elseif (($profile->service == "appdotnet") AND isset($post["url"]))
$post["text"] .= " ".$post["url"];
$message = array();