From 90964e0a14ad64d959c2f9d3789a7732fb73b8a3 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Thu, 27 Sep 2018 05:16:48 +0900 Subject: [PATCH] Create socialhub.utl.php --- helper/socialhub.utl.php | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 helper/socialhub.utl.php diff --git a/helper/socialhub.utl.php b/helper/socialhub.utl.php new file mode 100644 index 0000000..d1923ea --- /dev/null +++ b/helper/socialhub.utl.php @@ -0,0 +1,49 @@ + + * @brief SocialHub Utilities (refactoring from SocioRouter Utilities) + */ + +if(!function_exists("socialhub_send_message")) { + function socialhub_send_message($provider, $adapter, $message, $options=array()) { + $object_id = false; + + $response = false; + $status = array( + "message" => $message + ); + + switch($provider) { + case "facebook": + $status['link'] = get_value_in_array("link", $options, ""); + $status['picture'] = get_value_in_array("picture", $options, ""); + $response = $adapter->setUserStatus($status); + break; + + case "linkedin": + $status['content'] => array( + "title" => get_value_in_array("title", $options, ""); + "description" => get_value_in_array("description", $options, ""); + "submitted-url" => get_value_in_array("link", $options, ""); + "submitted-image-url" => get_value_in_array("picture", $options, ""); + ); + $status['visibility'] => array( + "code" => "anyone", + ); + $response = $adapter->setUserStatus($status); + break; + + case "twitter": + $status['link'] = get_value_in_array("link", $options, ""); + $status['picture'] = get_value_in_array("picture", $options, ""); + $response = $adapter->setUserStatus($status); + break; + + default: + set_error("Unknown provider"); + show_errors(); + } + } +}