mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-09 18:08:49 +00:00
app.net, facebook, twitter and statusnet: Preview now shows the post like it will appear on other networks.
This commit is contained in:
parent
f0efa3cae2
commit
9177ee2ecb
5 changed files with 166 additions and 4 deletions
|
@ -34,6 +34,7 @@ function fbpost_install() {
|
|||
register_hook('enotify', 'addon/fbpost/fbpost.php', 'fbpost_enotify');
|
||||
register_hook('queue_predeliver', 'addon/fbpost/fbpost.php', 'fbpost_queue_hook');
|
||||
register_hook('cron', 'addon/fbpost/fbpost.php', 'fbpost_cron');
|
||||
register_hook('prepare_body', 'addon/fbpost/fbpost.php', 'fbpost_prepare_body');
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,6 +46,7 @@ function fbpost_uninstall() {
|
|||
unregister_hook('enotify', 'addon/fbpost/fbpost.php', 'fbpost_enotify');
|
||||
unregister_hook('queue_predeliver', 'addon/fbpost/fbpost.php', 'fbpost_queue_hook');
|
||||
unregister_hook('cron', 'addon/fbpost/fbpost.php', 'fbpost_cron');
|
||||
unregister_hook('prepare_body', 'addon/fbpost/fbpost.php', 'fbpost_prepare_body');
|
||||
}
|
||||
|
||||
|
||||
|
@ -565,9 +567,11 @@ function fbpost_post_hook(&$a,&$b) {
|
|||
$msgarr = plaintext($a, $b, 0, false);
|
||||
$msg = $msgarr["text"];
|
||||
$link = $msgarr["url"];
|
||||
$image = $msgarr["image"];
|
||||
$linkname = $msgarr["title"];
|
||||
|
||||
if ($msgarr["type"] != "video")
|
||||
$image = $msgarr["image"];
|
||||
|
||||
// Fallback - if message is empty
|
||||
if(!strlen($msg))
|
||||
$msg = $linkname;
|
||||
|
@ -917,6 +921,23 @@ function fbpost_get_app_access_token() {
|
|||
}
|
||||
}
|
||||
|
||||
function fbpost_prepare_body(&$a,&$b) {
|
||||
if ($b["item"]["network"] != NETWORK_FACEBOOK)
|
||||
return;
|
||||
|
||||
if ($b["preview"]) {
|
||||
$msg = $b["item"]["body"];
|
||||
|
||||
require_once("include/bbcode.php");
|
||||
require_once("include/html2plain.php");
|
||||
$msg = bb_CleanPictureLinks($msg);
|
||||
$msg = bbcode($msg, false, false, 2, true);
|
||||
$msg = trim(html2plain($msg, 0));
|
||||
|
||||
$b['html'] = nl2br(htmlspecialchars($msg));
|
||||
}
|
||||
}
|
||||
|
||||
function fbpost_cron($a,$b) {
|
||||
$last = get_config('facebook','last_poll');
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue