public static function run_cron() { if (module_social::is_plugin_enabled() && self::is_plugin_enabled()) { $accounts = self::get_accounts(); foreach ($accounts as $account) { $facebook_account = new ucm_facebook_account($account['social_facebook_id']); /* @var $pages ucm_facebook_page[] */ $pages = $facebook_account->get('pages'); foreach ($pages as $page) { ob_start(); $page->graph_load_latest_page_data(); $output = ob_get_clean(); if (module_config::c('debug_cron_jobs', 0)) { echo $output; } } } } }
<?php /** * Copyright: dtbaker 2012 * Licence: Please check CodeCanyon.net for licence details. * More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ if (!module_social::can_i('edit', 'Facebook', 'Social', 'social')) { die('No access to Facebook accounts'); } $social_facebook_id = isset($_REQUEST['social_facebook_id']) ? (int) $_REQUEST['social_facebook_id'] : 0; $facebook = new ucm_facebook_account($social_facebook_id); $facebook_page_id = isset($_REQUEST['facebook_page_id']) ? (int) $_REQUEST['facebook_page_id'] : 0; /* @var $pages ucm_facebook_page[] */ $pages = $facebook->get('pages'); if (!$facebook_page_id || !$pages || !isset($pages[$facebook_page_id])) { die('No pages found to refresh'); } ?> Manually refreshing page data... <?php $pages[$facebook_page_id]->graph_load_latest_page_data();
<?php /** * Copyright: dtbaker 2012 * Licence: Please check CodeCanyon.net for licence details. * More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ if (module_social::can_i('view', 'Facebook Comments', 'Social', 'social')) { $social_facebook_id = isset($_REQUEST['social_facebook_id']) ? (int) $_REQUEST['social_facebook_id'] : 0; $facebook = new ucm_facebook_account($social_facebook_id); if ($social_facebook_id && $facebook->get('social_facebook_id') == $social_facebook_id) { $module->page_title = $facebook->get('facebook_name'); $header = array('title' => $facebook->get('facebook_name'), 'type' => 'h2', 'main' => true, 'button' => array()); if (module_social::can_i('create', 'Facebook Comments', 'Social', 'social')) { $header['button'] = array('url' => module_social_facebook::link_open_facebook_message($social_facebook_id, false), 'title' => _l('Compose Post'), 'type' => 'add', 'class' => 'socialfacebook_message_open social_modal', 'id' => 'socialfacebook_message_compose'); } print_heading($header); $search = isset($_REQUEST['search']) && is_array($_REQUEST['search']) ? $_REQUEST['search'] : array(); if (!isset($search['status'])) { $search['status'] = _SOCIAL_MESSAGE_STATUS_UNANSWERED; } /* @var $pages ucm_facebook_page[] */ $pages = $facebook->get('pages'); $all_messages = array(); foreach ($pages as $page) { $page_messages = $page->get_messages($search); $page_messages = query_to_array($page_messages);
* Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ if (!module_social::can_i('edit', 'Facebook', 'Social', 'social')) { die('No access to Facebook accounts'); } $social_facebook_id = isset($_REQUEST['social_facebook_id']) ? (int) $_REQUEST['social_facebook_id'] : 0; $facebook = new ucm_facebook_account($social_facebook_id); $heading = array('type' => 'h3', 'title' => 'Facebook Account'); ?> <form action="" method="post"> <input type="hidden" name="_process" value="save_facebook"> <input type="hidden" name="social_facebook_id" value="<?php echo $facebook->get('social_facebook_id'); ?> "> <?php module_form::print_form_auth(); $fieldset_data = array('heading' => $heading, 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array(array('title' => _l('Setup Instructions'), 'fields' => array(function () { ?> <p>Setup Instructions:</p> <ul> <li>Go to <a href="https://developers.facebook.com/apps" target="_blank">https://developers.facebook.com/apps</a> and click Create New App, choose "Website Option" </li> <li>Enter an App Name (e.g. MyBusinessName) and click "Create New Facebook App ID" and choose category "Apps for Pages".</li> <li>Click Skip Quick Start (top right)</li> <li>Copy the "App ID" and "App Secret" into the boxes below.</li>
public function handle_process($process, $options = array()) { switch ($process) { case 'send_social_message': check_admin_referer('social_send-message'); $message_count = 0; if (isset($options['social_message_id']) && (int) $options['social_message_id'] > 0 && isset($_POST['facebook_message']) && !empty($_POST['facebook_message'])) { // we have a social message id, ready to send! // which facebook accounts are we sending too? $facebook_accounts = isset($_POST['compose_facebook_id']) && is_array($_POST['compose_facebook_id']) ? $_POST['compose_facebook_id'] : array(); foreach ($facebook_accounts as $facebook_account_id => $send_pages) { $facebook_account = new ucm_facebook_account($facebook_account_id); if ($facebook_account->get('social_facebook_id') == $facebook_account_id) { /* @var $available_pages ucm_facebook_page[] */ $available_pages = $facebook_account->get('pages'); if ($send_pages) { foreach ($send_pages as $facebook_page_id => $tf) { if (!$tf) { continue; } // shouldnt happen // see if this is an available page. if (isset($available_pages[$facebook_page_id])) { // push to db! then send. $facebook_message = new ucm_facebook_message($facebook_account, $available_pages[$facebook_page_id], false); $facebook_message->create_new(); $facebook_message->update('social_facebook_page_id', $available_pages[$facebook_page_id]->get('social_facebook_page_id')); $facebook_message->update('social_message_id', $options['social_message_id']); $facebook_message->update('social_facebook_id', $facebook_account->get('social_facebook_id')); $facebook_message->update('summary', isset($_POST['facebook_message']) ? $_POST['facebook_message'] : ''); if (isset($_POST['track_links']) && $_POST['track_links']) { $facebook_message->parse_links(); } $facebook_message->update('type', 'pending'); $facebook_message->update('link', isset($_POST['link']) ? $_POST['link'] : ''); $facebook_message->update('data', json_encode($_POST)); $facebook_message->update('user_id', get_current_user_id()); // do we send this one now? or schedule it later. $facebook_message->update('status', _SOCIAL_MESSAGE_STATUS_PENDINGSEND); if (isset($options['send_time']) && !empty($options['send_time'])) { // schedule for sending at a different time (now or in the past) $facebook_message->update('last_active', $options['send_time']); } else { // send it now. $facebook_message->update('last_active', 0); } if (isset($_FILES['picture']['tmp_name']) && is_uploaded_file($_FILES['picture']['tmp_name'])) { $facebook_message->add_attachment($_FILES['picture']['tmp_name']); } $now = time(); if (!$facebook_message->get('last_active') || $facebook_message->get('last_active') <= $now) { // send now! otherwise we wait for cron job.. if ($facebook_message->send_queued(isset($_POST['debug']) && $_POST['debug'])) { $message_count++; } } else { $message_count++; if (isset($_POST['debug']) && $_POST['debug']) { echo "Message will be sent in cron job after " . print_date($facebook_message->get('last_active'), true); } } } else { // log error? } } } } } } return $message_count; break; case 'save_facebook': $social_facebook_id = isset($_REQUEST['social_facebook_id']) ? (int) $_REQUEST['social_facebook_id'] : 0; check_admin_referer('save-facebook' . $social_facebook_id); $facebook = new ucm_facebook_account($social_facebook_id); if (isset($_POST['butt_delete'])) { $facebook->delete(); $redirect = 'admin.php?page=simple_social_inbox_facebook_settings'; } else { $facebook->save_data($_POST); $social_facebook_id = $facebook->get('social_facebook_id'); if (isset($_POST['butt_save_reconnect'])) { $redirect = $facebook->link_connect(); } else { $redirect = $facebook->link_edit(); } } header("Location: {$redirect}"); exit; break; } }
?> </div> <div id="facebook_message_holder"> <?php $facebook_message->full_message_output(module_social::can_i('create', 'Facebook Comments', 'Social', 'social')); ?> </div> </form> <?php } } } if ($social_facebook_id && !$social_facebook_message_id && module_social::can_i('create', 'Facebook Comments', 'Social', 'social')) { $facebook = new ucm_facebook_account($social_facebook_id); if ($social_facebook_id && $facebook->get('social_facebook_id') == $social_facebook_id) { $module->page_title = $facebook->get('facebook_name'); /* @var $pages ucm_facebook_page[] */ $pages = $facebook->get('pages'); //print_r($pages); ?> <form action="" method="post" enctype="multipart/form-data"> <input type="hidden" name="_process" value="send_facebook_message"> <?php module_form::print_form_auth(); ?> <?php $fieldset_data = array('heading' => isset($_REQUEST['display_mode']) && $_REQUEST['display_mode'] == 'ajax' ? false : array('type' => 'h3', 'title' => 'Compose Message'), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array('facebook_page' => array('title' => _l('Facebook Page'), 'fields' => array()), 'message' => array('title' => _l('Message'), 'field' => array('type' => 'textarea', 'name' => 'message', 'id' => 'facebook_compose_message', 'value' => '')), 'type' => array('title' => _l('Type'), 'fields' => array('<input type="radio" name="post_type" id="post_type_wall" value="wall" checked> ', '<label for="post_type_wall">', _l('Wall Post'), '</label>', '<input type="radio" name="post_type" id="post_type_link" value="link"> ', '<label for="post_type_link">', _l('Link Post'), '</label>', '<input type="radio" name="post_type" id="post_type_picture" value="picture"> ', '<label for="post_type_picture">', _l('Picture Post'), '</label>')), 'link' => array('title' => _l('Link'), 'fields' => array(array('type' => 'text', 'name' => 'link', 'id' => 'message_link_url', 'value' => ''), '<div id="facebook_link_loading_message"></div>', '<span class="facebook-type-link facebook-type-option"></span>')), 'link_picture' => array('title' => _l('Link Picture'), 'fields' => array(array('type' => 'text', 'name' => 'link_picture', 'value' => ''), _hr('Full URL (eg: http://) to the picture to use for this link preview'), '<span class="facebook-type-link facebook-type-option"></span>')), 'link_name' => array('title' => _l('Link Title'), 'fields' => array(array('type' => 'text', 'name' => 'link_name', 'value' => ''), _hr('Title to use instead of the automatically generated one from the Link page'), '<span class="facebook-type-link facebook-type-option"></span>')), 'link_caption' => array('title' => _l('Link Caption'), 'fields' => array(array('type' => 'text', 'name' => 'link_caption', 'value' => ''), _hr('Caption to use instead of the automatically generated one from the Link page'), '<span class="facebook-type-link facebook-type-option"></span>')), 'link_description' => array('title' => _l('Link Description'), 'fields' => array(array('type' => 'text', 'name' => 'link_description', 'value' => ''), _hr('Description to use instead of the automatically generated one from the Link page'), '<span class="facebook-type-link facebook-type-option"></span>')), 'picture' => array('title' => _l('Picture'), 'fields' => array('<input type="file" name="picture" value="">', '<span class="facebook-type-picture facebook-type-option"></span>')), 'schedule' => array('title' => _l('Schedule'), 'fields' => array(array('type' => 'date', 'name' => 'schedule_date', 'value' => ''), array('type' => 'time', 'name' => 'schedule_time', 'value' => ''), ' ', _l('Currently: %s', date('c')), _hr('Leave blank to send now. Pick a date in the future to send this message.'))), 'debug' => array('title' => _l('Debug'), 'field' => array('type' => 'check', 'name' => 'debug', 'value' => '1', 'checked' => false, 'help' => 'Show debug output while posting the message')))); foreach ($pages as $facebook_page_id => $page) { $fieldset_data['elements']['facebook_page']['fields'][] = '<div id="facebook_compose_page_select">' . '<input type="checkbox" name="compose_page_id[' . $facebook_page_id . ']" value="1" checked> ' . '<img src="http://graph.facebook.com/' . $facebook_page_id . '/picture"> ' . htmlspecialchars($page->get('page_name')) . '</div>'; }
/** * Copyright: dtbaker 2012 * Licence: Please check CodeCanyon.net for licence details. * More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ if (!module_social::can_i('edit', 'Facebook', 'Social', 'social')) { die('No access to Facebook accounts'); } $social_facebook_id = isset($_REQUEST['social_facebook_id']) ? (int) $_REQUEST['social_facebook_id'] : 0; $facebook = new ucm_facebook_account($social_facebook_id); if ($facebook->get('social_facebook_id')) { // check for postback from our UCM facebook code handling script if (isset($_REQUEST['c'])) { $response = isset($_REQUEST['c']) ? @json_decode($_REQUEST['c'], true) : false; //print_r($response); if (!$response || !$response['code']) { die('Failed to get code from API, please press back and try again.'); } $code = $response['code']; // https://graph.facebook.com/oauth/access_token?code=...&client_id=...&redirect_uri=...&machine_id= ... $url = 'https://graph.facebook.com/oauth/access_token?code=' . urlencode($code) . '&redirect_uri=' . urlencode('http://ultimateclientmanager.com/api/facebook/logindone.php') . '&client_id=608055809278761'; $machine_id = isset($response['machine_id']) ? $response['machine_id'] : false; if ($machine_id) { $url .= '&machine_id=' . $machine_id; } $ch = curl_init($url);
$accounts = module_social_facebook::get_accounts(); foreach ($accounts as $account) { $facebook_account = new ucm_facebook_account($account['social_facebook_id']); ?> <tr class="<?php echo $c++ % 2 ? "odd" : "even"; ?> "> <td class="row_action"> <img src="<?php echo _BASE_HREF; ?> includes/plugin_social_facebook/images/facebook.png" class="facebook_icon"> <?php echo htmlspecialchars($facebook_account->get('facebook_name')); ?> <br/> </td> <td> <a href="<?php echo module_social_facebook::link_open_facebook_message($account['social_facebook_id'], false); ?> " class="socialfacebook_message_open social_modal btn btn-success btn-sm" data-modal-title="<?php _e('Compose Post'); ?> "><?php _e('Compose Post'); ?> </a> </td>