<?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");
}
}
}
if($access_token) {
$buffer = new BufferApp($client_id, $client_secret, $callback_url, $access_token);
- $result = q("SELECT `installed` FROM `addon` WHERE `name` = 'privacy_image_cache' AND `installed`");
- $image_cache = (count($result) > 0);
-
require_once("include/plaintext.php");
require_once("include/network.php");
$post = plaintext($a, $item, $limit, $includedlinks);
logger("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG);
- // The image cache is used as a sanitizer. Buffer seems to be really picky about pictures
- if ($image_cache) {
- require_once("addon/privacy_image_cache/privacy_image_cache.php");
- if (isset($post["image"]))
- $post["image"] = $a->get_baseurl() . "/privacy_image_cache/".privacy_image_cache_cachename($post["image"]);
+ // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures
+ require_once("mod/proxy.php");
+ if (isset($post["image"]))
+ $post["image"] = proxy_url($post["image"]);
- if (isset($post["preview"]))
- $post["preview"] = $a->get_baseurl() . "/privacy_image_cache/".privacy_image_cache_cachename($post["preview"]);
- }
+ if (isset($post["preview"]))
+ $post["preview"] = proxy_url($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();