X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=ifttt%2Fifttt.php;h=ddd517e2603bcd333a965172a33fd6d0e2698597;hb=c3e93f1ed9a487f823bcc75ddd43024334c25bfc;hp=3203fec46921cd372e9becaebe66ddecb273028c;hpb=b1421328dd2a8d13a2904fb138e87e6111202bda;p=friendica-addons.git
diff --git a/ifttt/ifttt.php b/ifttt/ifttt.php
index 3203fec4..ddd517e2 100644
--- a/ifttt/ifttt.php
+++ b/ifttt/ifttt.php
@@ -9,6 +9,8 @@
require_once("mod/item.php");
require_once("include/items.php");
+use Friendica\Core\PConfig;
+
function ifttt_install() {
register_hook('connector_settings', 'addon/ifttt/ifttt.php', 'ifttt_settings');
register_hook('connector_settings_post','addon/ifttt/ifttt.php', 'ifttt_settings_post');
@@ -30,11 +32,11 @@ function ifttt_settings(&$a,&$s) {
if(! local_user())
return;
- $key = get_pconfig(local_user(),'ifttt','key');
+ $key = PConfig::get(local_user(),'ifttt','key');
if (!$key) {
$key = substr(random_string(),0,20);
- set_pconfig(local_user(),'ifttt','key', $key);
+ PConfig::set(local_user(),'ifttt','key', $key);
}
$s .= '';
@@ -46,9 +48,9 @@ function ifttt_settings(&$a,&$s) {
$s .= '';
$s .= '
';
- $s .= '
'.t("Create an account at IFTTT. Create three Facebook recipes that are connected with 'Maker' with the following parameters:").'
';
+ $s .= '
'.t("Create an account at IFTTT. Create three Facebook recipes that are connected with Maker (In the form 'if Facebook then Maker') with the following parameters:").'
';
$s .= '
URL
';
- $s .= '
'.$a->get_baseurl()."/ifttt/".'
';
+ $s .= '
' . $a->get_baseurl() . '/ifttt/' . $a->user['nickname'] . '
';
$s .= '
Method
';
$s .= '
POST
';
$s .= '
Content Type
';
@@ -102,7 +104,7 @@ function ifttt_post(&$a) {
$key = $_REQUEST["key"];
// Check the key
- if ($key != get_pconfig($uid,'ifttt','key')) {
+ if ($key != PConfig::get($uid,'ifttt','key')) {
logger("Invalid key for user ".$uid, LOGGER_DEBUG);
return;
}
@@ -132,7 +134,7 @@ function ifttt_post(&$a) {
if (isset($_REQUEST["url"]))
$item["url"] = trim($_REQUEST["url"]);
- if ((substr($item["msg"], 0, 3) == "<<<") AND (substr($item["msg"], -3, 3) == ">>>"))
+ if ((substr($item["msg"], 0, 3) == "<<<") && (substr($item["msg"], -3, 3) == ">>>"))
$item["msg"] = substr($item["msg"], 3, -3);
ifttt_message($uid, $item);
@@ -155,23 +157,25 @@ function ifttt_message($uid, $item) {
//$_REQUEST["date"] = $item["date"];
//$_REQUEST["uri"] = $item["url"];
- if (strstr($item["url"], "facebook.com"))
+ if (strstr($item["url"], "facebook.com")) {
+ $hash = hash("ripemd128", item["url"]);
$_REQUEST["extid"] = NETWORK_FACEBOOK;
+ $_REQUEST['message_id'] = item_new_uri($a->get_hostname(), $uid, NETWORK_FACEBOOK.":".$hash);
+ }
if ($item["type"] == "link") {
$data = query_page_info($item["link"]);
- if (isset($item["title"]) AND (trim($item["title"]) != ""))
+ if (isset($item["title"]) && (trim($item["title"]) != ""))
$data["title"] = $item["title"];
- if (isset($item["description"]) AND (trim($item["description"]) != ""))
+ if (isset($item["description"]) && (trim($item["description"]) != ""))
$data["text"] = $item["description"];
$_REQUEST["body"] .= add_page_info_data($data);
- } elseif (($item["type"] == "photo") AND ($item["image"] != ""))
+ } elseif (($item["type"] == "photo") && ($item["image"] != ""))
$_REQUEST["body"] .= "\n\n[img]".$item["image"]."[/img]\n";
//print_r($_REQUEST);
item_post($a);
}
-?>