当前位置: 首页>>代码示例>>PHP>>正文


PHP Social::log方法代码示例

本文整理汇总了PHP中Social::log方法的典型用法代码示例。如果您正苦于以下问题:PHP Social::log方法的具体用法?PHP Social::log怎么用?PHP Social::log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Social的用法示例。


在下文中一共展示了Social::log方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: verify_nonce

 protected function verify_nonce()
 {
     $nonce = $this->request->query('_wpnonce');
     if (!Social::wp39_verify_nonce($nonce, $this->request->action())) {
         Social::log('NONCE Failure', array(), null, true);
         wp_die('Oops, please try again.');
     }
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:8,代码来源:controller.php

示例2: action_from_url

 /**
  * Imports a tweet by URL.
  *
  * @return void
  */
 public function action_from_url()
 {
     $this->verify_nonce();
     Social::log('Import tweet by URL started.');
     $service = $this->social->service('twitter');
     if ($service !== false) {
         $response = $service->import_tweet_by_url($this->request->query('post_id'), $this->request->query('url'));
         if ($response !== true) {
             echo $response;
             exit;
         }
         Social::log('Import tweet by URL finished.');
     } else {
         Social::log('Import tweet by URL failed, Twitter class not found.');
     }
     echo Social_Aggregation_Log::instance($this->request->query('post_id'));
     exit;
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:23,代码来源:import.php

示例3: action_check_crons

 /**
  * Makes sure Social CRONs are not scheduled more than once.
  *
  * @return void
  */
 public function action_check_crons()
 {
     // this is an internal only call, so manually calling URL decode
     if (urldecode($this->request->query('social_api_key')) != Social::option('system_cron_api_key')) {
         Social::log('API key failed');
         wp_die('Oops, invalid API key.');
     }
     $crons = _get_cron_array();
     $social_crons = array('15' => false);
     foreach ($crons as $timestamp => $_crons) {
         foreach ($_crons as $key => $cron) {
             foreach ($social_crons as $cron_key => $status) {
                 $event_key = 'social_cron_' . $cron_key . '_core';
                 if ($key == $event_key and $social_crons[$cron_key]) {
                     wp_unschedule_event($timestamp, $event_key);
                     Social::log('Unscheduled extra event: ' . $event_key);
                 } else {
                     $social_crons[$cron_key] = true;
                 }
             }
         }
     }
 }
开发者ID:nick5a1,项目名称:wp-social,代码行数:28,代码来源:cron.php

示例4: action_run

 /**
  * Runs the aggregation for the requested post ID.
  *
  * @return void
  */
 public function action_run()
 {
     $this->verify_nonce();
     $fetch = Social::option('aggregate_comments');
     if (empty($fetch)) {
         Social::log('Aggregation has been disabled, exiting.');
         return;
     }
     $post = get_post($this->request->query('post_id'));
     if ($post === null) {
         return;
     }
     Social::log('Begin aggregation for post #:post_id.', array('post_id' => $post->ID));
     // Get URLs to query
     $default_urls = array(home_url('?p=' . $post->ID));
     $url = wp_get_shortlink($post->ID);
     if (strpos($url, '?p=') === false) {
         $default_urls[] = $url;
     }
     // Add the permalink?
     $permalink = get_permalink($post->ID);
     if ($default_urls[0] != $permalink) {
         $default_urls[] = $permalink;
     }
     $broadcasted_ids = get_post_meta($post->ID, '_social_broadcasted_ids', true);
     if (empty($broadcasted_ids)) {
         $broadcasted_ids = array();
     }
     $aggregated_ids = get_post_meta($post->ID, '_social_aggregated_ids', true);
     if (empty($aggregated_ids)) {
         $aggregated_ids = array();
     }
     $post->broadcasted_ids = $broadcasted_ids;
     $post->aggregated_ids = $aggregated_ids;
     $post->results = array();
     foreach ($this->social->services() as $key => $service) {
         $urls = $default_urls;
         $post->results[$key] = array();
         if (!isset($post->aggregated_ids[$key])) {
             $post->aggregated_ids[$key] = array();
         }
         if (isset($broadcasted_ids[$key]) and count($broadcasted_ids[$key])) {
             $service->aggregate_by_api($post);
             foreach ($broadcasted_ids[$key] as $broadcasted) {
                 foreach ($broadcasted as $data) {
                     if (isset($data['urls']) and is_array($data['urls'])) {
                         foreach ($data['urls'] as $url) {
                             $urls[] = $url;
                         }
                     }
                 }
             }
         }
         // URL Search
         $urls = apply_filters('social_search_urls', $urls, $key);
         $urls = array_unique($urls);
         if (count($urls)) {
             foreach ($urls as $key => $url) {
                 $urls[$key] = urlencode($url);
             }
             $service->aggregate_by_url($post, $urls);
         }
     }
     if (count($post->results)) {
         foreach ($post->results as $key => $results) {
             if (count($results)) {
                 $this->social->service($key)->save_aggregated_comments($post);
             }
         }
         update_post_meta($post->ID, '_social_aggregated_ids', $post->aggregated_ids);
     }
     Social::log('Aggregation for post #:post_id complete.', array('post_id' => $post->ID));
     // Some cleanup...
     unset($post->broadcasted_ids);
     unset($post->aggregated_ids);
     unset($post->results);
     if ($this->request->is_ajax()) {
         // Re-add to the queue?
         $queue = Social_Aggregation_Queue::factory();
         if (!$queue->find($post->ID)) {
             $queue->add($post->ID, '24hr')->save();
         }
         $log = Social_Aggregation_Log::instance($post->ID);
         $log->save(true);
         if (isset($_GET['render']) and $_GET['render'] == 'false') {
             $total = 0;
             $log = $log->current();
             if (isset($log->items)) {
                 foreach ($log->items as $service => $items) {
                     foreach ($items as $item) {
                         if (!$item->ignored) {
                             ++$total;
                         }
                     }
                 }
//.........这里部分代码省略.........
开发者ID:Blueprint-Marketing,项目名称:interoccupy.net,代码行数:101,代码来源:aggregation.php

示例5: action_reload_form

 /**
  * Renders the new comment form.
  *
  * @return void
  */
 public function action_reload_form()
 {
     if (!$this->request->is_ajax()) {
         exit;
     }
     if (isset($_COOKIE['social_auth_nonce'])) {
         $cookie_nonce = stripslashes($_COOKIE['social_auth_nonce']);
         // Find the user by NONCE.
         global $wpdb;
         $user_id = $wpdb->get_var($wpdb->prepare("\n\t\t\t\tSELECT user_id\n\t\t\t\t  FROM {$wpdb->usermeta}\n\t\t\t\t WHERE meta_key = %s\n\t\t\t", 'social_auth_nonce_' . $cookie_nonce));
         if ($user_id !== null) {
             Social::log('Found user #:id using nonce :nonce.', array('id' => $user_id, 'nonce' => $cookie_nonce));
             // Log the user in
             wp_set_current_user($user_id);
             add_filter('auth_cookie_expiration', array($this->social, 'auth_cookie_expiration'));
             wp_set_auth_cookie($user_id, true);
             remove_filter('auth_cookie_expiration', array($this->social, 'auth_cookie_expiration'));
             delete_user_meta($user_id, 'social_auth_nonce_' . $cookie_nonce);
             setcookie('social_auth_nonce', '', -3600, '/');
             $post_id = $this->request->query('post_id');
             $form = trim(Social_Comment_Form::instance($post_id)->render());
             echo json_encode(array('result' => 'success', 'html' => $form, 'disconnect_url' => wp_loginout('', false)));
         } else {
             Social::log('Failed to find the user using nonce :nonce.', array('nonce' => $_COOKIE['social_auth_nonce']));
             echo json_encode(array('result' => 'error', 'html' => 'not logged in'));
         }
     } else {
         echo json_encode(array('result' => 'error', 'html' => 'not logged in'));
     }
     exit;
 }
开发者ID:USSLomaPrieta,项目名称:usslomaprieta.org,代码行数:36,代码来源:auth.php

示例6: action_run

 /**
  * Broadcasts a post to the services.
  *
  * @param  int|WP_Post  $post_id  post id or post object
  * @return void
  */
 public function action_run($post_id = null)
 {
     if ($post_id === null) {
         $post_id = intval($this->request->query('post_ID'));
     }
     $post = $post_id;
     if (is_int($post_id)) {
         $post = get_post($post_id);
     }
     if ($post === null) {
         Social::log('Failed to broadcast post :post_id.', array('post_id' => $post_id));
         return;
     }
     // Load content to broadcast (accounts, broadcast message, etc)
     $personal_accounts = null;
     $errored_accounts = false;
     $broadcast_accounts = get_post_meta($post->ID, '_social_broadcast_accounts', true);
     $broadcasted_ids = get_post_meta($post->ID, '_social_broadcasted_ids', true);
     if (empty($broadcasted_ids)) {
         $broadcasted_ids = array();
     }
     $account_content = get_post_meta($post->ID, '_social_broadcast_content', true);
     if (empty($account_content)) {
         $account_content = array();
     }
     $account_meta = get_post_meta($post->ID, '_social_broadcast_meta', true);
     if (empty($account_meta)) {
         $account_meta = array();
     }
     Social::log('About to start broadcasting.');
     foreach ($broadcast_accounts as $key => $accounts) {
         Social::log('Loading service :service', array('service' => $key));
         $service = $this->social->service($key);
         if ($service) {
             Social::log('Found service :service', array('service' => $key));
             foreach ($accounts as $_account) {
                 if ($_account->universal != '1') {
                     if ($personal_accounts === null) {
                         $personal_accounts = get_user_meta($post->post_author, 'social_accounts', true);
                     }
                     if (isset($personal_accounts[$key][$_account->id])) {
                         $class = 'Social_Service_' . $key . '_Account';
                         $account = new $class($personal_accounts[$key][$_account->id]);
                     } else {
                         $account = false;
                     }
                 } else {
                     $account = $service->account($_account->id);
                 }
                 if ($account == false) {
                     $account = apply_filters('social_get_broadcast_account', $_account, $post, $service);
                 }
                 if ($account !== false) {
                     // Load the message
                     $message = '';
                     if (isset($account_content[$key][$_account->id])) {
                         $message = $account_content[$key][$_account->id];
                     }
                     $args = array();
                     if (isset($account_meta[$key][$_account->id])) {
                         $args = $account_meta[$key][$_account->id];
                     }
                     if (!empty($message)) {
                         Social::log('Broadcasting to :username, account #:id. (:service)', array('id' => $account->id(), 'username' => $account->name(), 'service' => $service->title()));
                         $response = $service->broadcast($account, $message, $args, $post->ID);
                         if ($response !== false) {
                             if ($response->limit_reached()) {
                                 if (!isset($errored_accounts[$key])) {
                                     $errored_accounts[$key] = array();
                                 }
                                 $reason = __('Rate limit reached', 'social');
                                 $errored_accounts[$key][] = (object) array('account' => $account, 'reason' => $reason, 'type' => 'limit_reached');
                                 Social::log('Broadcasting to :username, account #:id FAILED. Reason: :reason', array('id' => $account->id(), 'username' => $account->name(), 'reason' => $reason));
                             } else {
                                 if ($response->duplicate_status()) {
                                     if (!isset($errored_accounts[$key])) {
                                         $errored_accounts[$key] = array();
                                     }
                                     $reason = __('Duplicate status', 'social');
                                     $errored_accounts[$key][] = (object) array('account' => $account, 'reason' => $reason, 'type' => 'duplicate_status');
                                     Social::log('Broadcasting to :username, account #:id FAILED. Reason: :reason', array('id' => $account->id(), 'username' => $account->name(), 'reason' => $reason));
                                 } else {
                                     if ($response->deauthorized() or $response->deauthorized(true)) {
                                         if (!isset($errored_accounts[$key])) {
                                             $errored_accounts[$key] = array();
                                         }
                                         $reason = __('Account deauthorized', 'social');
                                         $errored_accounts[$key][] = (object) array('account' => $account, 'reason' => $reason, 'deauthed' => true);
                                         Social::log('Broadcasting to :username, account #:id FAILED. Reason: :reason', array('id' => $account->id(), 'username' => $account->name(), 'reason' => $reason));
                                     } else {
                                         if ($response->general_error()) {
                                             if (!isset($errored_accounts[$key])) {
                                                 $errored_accounts[$key] = array();
                                             }
//.........这里部分代码省略.........
开发者ID:Blueprint-Marketing,项目名称:interoccupy.net,代码行数:101,代码来源:broadcast.php

示例7: get_also_post_to_controls

 /**
  * Outputs checkboxes for cross-posting
  * 
  * @uses Social::to_tag()
  * @return string
  */
 public function get_also_post_to_controls()
 {
     if ($this->is_logged_in and $this->post->post_status != 'private') {
         $id = 'post_to_service';
         $label_base = array('for' => $id, 'id' => 'post_to');
         $checkbox = $this->to_tag('input', false, array('type' => 'checkbox', 'name' => $id, 'id' => $id, 'value' => 1));
         if (current_user_can('manage_options')) {
             $text = sprintf(__('Also post to %s', 'social'), '<span></span>');
             $post_to = $this->to_tag('label', $checkbox . ' ' . $text, $label_base, array('style' => 'display:none;'));
         } else {
             $post_to = '';
             foreach (Social::instance()->services() as $key => $service) {
                 if (count($service->accounts())) {
                     Social::log(print_r($service->accounts(), true));
                     foreach ($service->accounts() as $account) {
                         if ($account->personal()) {
                             $text = sprintf(__('Also post to %s', 'social'), $service->title());
                             $post_to .= $this->to_tag('label', $checkbox . ' ' . $text, $label_base);
                             break;
                         }
                     }
                 }
             }
         }
         return $post_to;
     }
     return '';
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:34,代码来源:form.php

示例8: action_retrieve_twitter_content

 /**
  * Retrieves missing Twitter content.
  *
  * @return void
  */
 public function action_retrieve_twitter_content()
 {
     $this->verify_nonce();
     $broadcasted_id = $this->request->query('broadcasted_id');
     if ($broadcasted_id === null) {
         exit;
     }
     $post_id = $this->request->query('post_id');
     if ($post_id !== null) {
         $recovered = false;
         $run = get_post_meta('_social_run_twitter_retrieval', true);
         if (empty($run) or (int) $run <= current_time('timestamp', 1)) {
             Social::log('Running Twitter retrieval on post #:post_id for broadcasted #:broadcasted_id.', array('post_id' => $post_id, 'broadcasted_id' => $broadcasted_id));
             // Do we have accounts to use?
             $service = Social::instance()->service('twitter');
             if ($service !== false) {
                 $accounts = $service->accounts();
                 if (count($accounts)) {
                     foreach ($accounts as $account) {
                         Social::log('Using account #:account_id.', array('account_id' => $account->id()));
                         // Run the request to the find Tweet
                         $response = $service->request($account, 'statuses/show/' . $broadcasted_id);
                         if ($response !== false and $response->body()->result != 'error') {
                             $recovered = $service->recovered_meta($post_id, $broadcasted_id, $response->body()->response);
                         }
                         Social::log('Response: :response', array('response' => print_r($response, true)));
                     }
                 } else {
                     Social::log('Using public API, no accounts found.');
                     $response = wp_remote_get('http://api.twitter.com/1/statuses/show/' . $broadcasted_id . '.json');
                     if (!is_wp_error($response) and !isset($response->error)) {
                         $recovered = $service->recovered_meta($post_id, $broadcasted_id, $response);
                     }
                     Social::log('Response: :response', array('response' => print_r($response, true)));
                 }
             } else {
                 Social::log('Failed, Twitter class not found.');
             }
         }
         if (!$recovered) {
             Social::log('Failed to recover the data, try again in 15 minutes.');
             // Something went wrong, retry again in 15 minutes.
             update_post_meta($post_id, '_social_run_twitter_retrieval', current_time('timestamp', 1) + 54000);
         } else {
             if (!empty($run)) {
                 Social::log('Content found, cya!');
                 delete_post_meta($post_id, '_social_run_twitter_retrieval');
             }
         }
     }
 }
开发者ID:nick5a1,项目名称:wp-social,代码行数:56,代码来源:aggregation.php

示例9: stuck_check

 /**
  * Attempts to jiggle the stuck lock loose.
  *
  * @return bool
  */
 private function stuck_check()
 {
     global $wpdb;
     // Check to see if we already broke the lock.
     if ($this->lock_broke) {
         return true;
     }
     $current_time = current_time('mysql', 1);
     $unlock_time = gmdate('Y-m-d H:i:s', time() - 30 * 60);
     $affected = $wpdb->query($wpdb->prepare("\n\t\t\tUPDATE {$wpdb->options}\n\t\t\t   SET option_value = %s\n\t\t\t WHERE option_name = 'social_last_lock_time'\n\t\t\t   AND option_value <= %s\n\t\t", $current_time, $unlock_time));
     if ($affected == '1') {
         Social::log('Semaphore was stuck, set lock time to ' . $current_time);
         $this->lock_broke = true;
         return true;
     }
     return false;
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:22,代码来源:semaphore.php

示例10: import_tweet_by_url

 /**
  * Imports a Tweet by URL.
  *
  * @param  int     $post_id
  * @param  string  $url
  * @return bool|string
  */
 public function import_tweet_by_url($post_id, $url)
 {
     if (!($account = $this->api_account())) {
         return;
     }
     $post = get_post($post_id);
     $post->broadcasted_ids = get_post_meta($post->ID, '_social_broadcasted_ids', true);
     if (empty($post->broadcasted_ids)) {
         $post->broadcasted_ids = array();
     }
     $invalid = false;
     $id = $this->tweet_url_to_id($url);
     if (!empty($id) and !$this->is_original_broadcast($post, $id)) {
         Social::log('Importing tweet. -- ID: :id -- URL: :url', array("id" => $id, "url" => $url));
         $social_response = $this->request($account, '1.1/statuses/show/' . $id, array('include_entities' => 'true'));
         error_log(print_r($social_response, true));
         if ($social_response !== false and is_object($social_response->body()->response)) {
             $response = $social_response->body()->response;
             if ($response !== null and !isset($response->error)) {
                 $logger = Social_Aggregation_Log::instance($post->ID);
                 $post->aggregated_ids = get_post_meta($post->ID, '_social_aggregated_ids', true);
                 if (empty($post->aggregated_ids)) {
                     $post->aggregated_ids = array();
                 }
                 if (!isset($post->aggregated_ids[$this->_key])) {
                     $post->aggregated_ids[$this->_key] = array();
                 }
                 if (in_array($id, $post->aggregated_ids[$this->_key])) {
                     $logger->add($this->_key, $response->id, 'Imported', true, array('username' => $response->user->screen_name));
                 } else {
                     $logger->add($this->_key, $response->id, 'Imported', false, array('username' => $response->user->screen_name));
                     $post->aggregated_ids[$this->_key][] = $response->id;
                     $post->results = array($this->_key => array($response->id => (object) array('id' => $response->id, 'from_user_id' => $response->user->id, 'from_user' => $response->user->screen_name, 'text' => $response->text, 'created_at' => $response->created_at, 'profile_image_url' => $response->user->profile_image_url, 'profile_image_url_https' => $response->user->profile_image_url_https, 'in_reply_to_status_id' => $response->in_reply_to_status_id, 'raw' => $response, 'comment_type' => 'social-twitter')));
                     $this->save_aggregated_comments($post, true);
                     // Some cleanup...
                     unset($post->aggregated_ids);
                     unset($post->results);
                 }
                 $logger->save(true);
             } else {
                 Social::log('Something went wrong... -- :response', array('response' => print_r($response, true)));
                 if (isset($response->error)) {
                     if ($response->error == 'Sorry, you are not authorized to see this status.') {
                         return 'protected';
                     } else {
                         $invalid = true;
                     }
                 }
             }
         } else {
             $invalid = true;
         }
     } else {
         Social::log('Something went wrong... -- ID: :id -- URL: :url', array('id' => $id, 'url' => implode('/', $url)));
         $invalid = true;
     }
     unset($post->broadcasted_ids);
     if ($invalid) {
         return 'invalid';
     }
     return true;
 }
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:69,代码来源:twitter.php

示例11: remove

 /**
  * Removes a post from the queue completely, or by timestamp.
  *
  * @param  int  $post_id    post id
  * @param  int  $timestamp  (optional) timestamp to remove by
  * @return Social_Aggregation_Queue
  */
 public function remove($post_id, $timestamp = null)
 {
     $unset = false;
     if ($timestamp === null) {
         $queue = array();
         foreach ($this->_queue as $timestamp => $posts) {
             foreach ($posts as $id => $interval) {
                 if ($id !== $post_id) {
                     if (!isset($queue[$timestamp])) {
                         $queue[$timestamp] = array();
                     }
                     $queue[$timestamp][$id] = $interval;
                 } else {
                     $unset = true;
                 }
             }
         }
         $this->_queue = $queue;
     } else {
         if (isset($this->_queue[$timestamp]) and isset($this->_queue[$timestamp][$post_id])) {
             $unset = true;
             unset($this->_queue[$timestamp][$post_id]);
             if (empty($this->_queue[$timestamp])) {
                 unset($this->_queue[$timestamp]);
             }
         }
     }
     if ($unset) {
         delete_post_meta($post_id, '_social_aggregation_next_run');
         $this->save();
         Social::log('Post #:post_id removed from the aggregation queue.', array('post_id' => $post_id));
     }
     return $this;
 }
开发者ID:nick5a1,项目名称:wp-social,代码行数:41,代码来源:queue.php

示例12: import_tweet_by_url

 /**
  * Imports a Tweet by URL.
  *
  * @param  int     $post_id
  * @param  string  $url
  * @return bool|string
  */
 public function import_tweet_by_url($post_id, $url)
 {
     $post = get_post($post_id);
     $post->broadcasted_ids = get_post_meta($post->ID, '_social_broadcasted_ids', true);
     if (empty($post->broadcasted_ids)) {
         $post->broadcasted_ids = array();
     }
     $invalid = false;
     $id = $this->tweet_url_to_id($url);
     if (!empty($id) and !$this->is_original_broadcast($post, $id)) {
         Social::log('Importing tweet. -- ID: :id -- URL: :url');
         $url = 'http://api.twitter.com/1/statuses/show.json?id=' . $id;
         $request = wp_remote_get($url);
         if (!is_wp_error($request)) {
             $response = apply_filters('social_response_body', $request['body'], $this->_key);
             if ($response !== null and !isset($response->error)) {
                 $logger = Social_Aggregation_Log::instance($post->ID);
                 $post->aggregated_ids = get_post_meta($post->ID, '_social_aggregated_ids', true);
                 if (empty($post->aggregated_ids)) {
                     $post->aggregated_ids = array();
                 }
                 if (!isset($post->aggregated_ids[$this->_key])) {
                     $post->aggregated_ids[$this->_key] = array();
                 }
                 if (in_array($id, $post->aggregated_ids[$this->_key])) {
                     $logger->add($this->_key, $response->id, 'Imported', true, array('username' => $response->user->screen_name));
                 } else {
                     $logger->add($this->_key, $response->id, 'Imported', false, array('username' => $response->user->screen_name));
                     $post->aggregated_ids[$this->_key][] = $response->id;
                     $post->results[$this->_key][$response->id] = (object) array('id' => $response->id, 'from_user_id' => $response->user->id, 'from_user' => $response->user->screen_name, 'text' => $response->text, 'created_at' => $response->created_at, 'profile_image_url' => $response->user->profile_image_url, 'in_reply_to_status_id' => $response->in_reply_to_status_id, 'raw' => $response, 'comment_type' => 'social-twitter');
                     $this->save_aggregated_comments($post, true);
                     // Some cleanup...
                     unset($post->aggregated_ids);
                     unset($post->results);
                 }
                 $logger->save(true);
             } else {
                 Social::log('Something went wrong... -- :response', array('response' => print_r($response, true)));
                 if (isset($response->error)) {
                     if ($response->error == 'Sorry, you are not authorized to see this status.') {
                         return 'protected';
                     } else {
                         $invalid = true;
                     }
                 }
             }
         } else {
             Social::log('Something went wrong... -- :response', array('response' => print_r($request, true)));
             $invalid = true;
         }
     } else {
         Social::log('Something went wrong... -- ID: :id -- URL: :url', array('id' => $id, 'url' => implode('/', $url)));
         $invalid = true;
     }
     unset($post->broadcasted_ids);
     if ($invalid) {
         return 'invalid';
     }
     return true;
 }
开发者ID:nick5a1,项目名称:wp-social,代码行数:67,代码来源:twitter.php

示例13: save_aggregated_comments

 /**
  * Saves the aggregated comments.
  *
  * @param  object  $post
  * @return void
  */
 public function save_aggregated_comments(&$post)
 {
     if (isset($post->results[$this->_key])) {
         global $wpdb;
         foreach ($post->results[$this->_key] as $result) {
             $commentdata = array('comment_post_ID' => $post->ID, 'comment_author_email' => $wpdb->escape($this->_key . '.' . $result->id . '@example.com'), 'comment_author_IP' => $_SERVER['SERVER_ADDR'], 'comment_agent' => 'Social Aggregator');
             if (!isset($result->like)) {
                 $url = 'http://graph.facebook.com/' . $result->from->id;
                 $request = wp_remote_get($url);
                 if (!is_wp_error($request)) {
                     $response = json_decode($request['body']);
                     $account = (object) array('user' => $response);
                     $class = 'Social_Service_' . $this->_key . '_Account';
                     $account = new $class($account);
                     $commentdata = array_merge($commentdata, array('comment_type' => 'social-facebook', 'comment_author' => $wpdb->escape($result->from->name), 'comment_author_url' => $account->url(), 'comment_content' => $wpdb->escape($result->message), 'comment_date' => date('Y-m-d H:i:s', strtotime($result->created_time) + get_option('gmt_offset') * 3600), 'comment_date_gmt' => gmdate('Y-m-d H:i:s', strtotime($result->created_time))));
                 }
             } else {
                 $url = 'http://facebook.com/profile.php?id=' . $result->id;
                 $commentdata = array_merge($commentdata, array('comment_type' => 'social-facebook-like', 'comment_author' => $wpdb->escape($result->name), 'comment_author_url' => $url, 'comment_content' => $wpdb->escape('<a href="' . $url . '" target="_blank">' . $result->name . '</a> liked this on Facebook.'), 'comment_date' => current_time('mysql'), 'comment_date_gmt' => current_time('mysql', 1)));
             }
             $user_id = isset($result->like) ? $result->id : $result->from->id;
             $commentdata = array_merge($commentdata, array('comment_post_ID' => $post->ID, 'comment_author_email' => $this->_key . '.' . $user_id . '@example.com'));
             $result_id = isset($result->status_id) ? $result->status_id : $result->id;
             if (apply_filters('social_approve_likes_and_retweets', true) && isset($result->like)) {
                 $commentdata['comment_approved'] = 1;
             } else {
                 if (($commentdata = $this->allow_comment($commentdata, $result_id, $post)) === false) {
                     continue;
                 }
             }
             // sanity check to make sure this comment is not a duplicate
             if ($this->is_duplicate_comment($post, $result->id)) {
                 Social::log('Result #:result_id already exists, skipping.', array('result_id' => $result->id), 'duplicate-comment');
                 continue;
             }
             Social::log('Saving #:result_id.', array('result_id' => isset($result->status_id) ? $result->status_id : $result->id));
             $comment_id = 0;
             try {
                 Social::Log('Attempting to save commentdata: :commentdata', array('commentdata' => print_r($commentdata, true)));
                 $comment_id = wp_insert_comment($commentdata);
                 update_comment_meta($comment_id, 'social_account_id', addslashes_deep($user_id));
                 update_comment_meta($comment_id, 'social_profile_image_url', addslashes_deep('http://graph.facebook.com/' . $user_id . '/picture'));
                 update_comment_meta($comment_id, 'social_status_id', addslashes_deep(isset($result->status_id) ? $result->status_id : $result->id));
                 if (!isset($result->raw)) {
                     $result = (object) array_merge((array) $result, array('raw' => $result));
                 }
                 update_comment_meta($comment_id, 'social_raw_data', addslashes_deep(base64_encode(json_encode($result->raw))));
                 if ($commentdata['comment_approved'] !== 'spam') {
                     if ($commentdata['comment_approved'] == '0') {
                         wp_notify_moderator($comment_id);
                     }
                     if (get_option('comments_notify') and $commentdata['comment_approved'] and (!isset($commentdata['user_id']) or $post->post_author != $commentdata['user_id'])) {
                         wp_notify_postauthor($comment_id, 'comment');
                     }
                 }
             } catch (Exception $e) {
                 // Something went wrong, remove the aggregated ID.
                 if (($key = array_search(isset($result->status_id) ? $result->status_id : $result->id, $post->aggregated_ids['facebook'])) !== false) {
                     unset($post->aggregated_ids['facebook'][$key]);
                 }
                 if ((int) $comment_id) {
                     // Delete the comment in case it wasn't the insert that failed.
                     wp_delete_comment($comment_id);
                 }
             }
         }
     }
 }
开发者ID:Blueprint-Marketing,项目名称:interoccupy.net,代码行数:74,代码来源:facebook.php

示例14: array

                             Social::log('Current Meta Value: :meta_value', array('meta_value' => print_r($_meta_value, true)));
                             if (is_scalar($data)) {
                                 $_meta_value[$service_key][$account_id][$data] = array('message' => '');
                             } else {
                                 $_meta_value[$service_key][$account_id][$id] = $data;
                             }
                         }
                     } else {
                         $_meta_value[$service_key][$account_id][$broadcasted] = array('message' => '');
                     }
                 }
             }
             if (!empty($_meta_value)) {
                 update_post_meta($result->post_id, '_social_broadcasted_ids', $_meta_value);
             }
             Social::log('New meta value for post #:post_id: :meta_value', array('post_id' => $result->post_id, 'meta_value' => print_r($_meta_value, true)));
         }
     }
 }
 // Add broadcast by default
 Social::option('broadcast_by_default', '0');
 // Reschedule posts for aggregation
 $results = $wpdb->get_results("\n\t\tSELECT post_id\n\t\tFROM {$wpdb->postmeta}\n\t\tWHERE meta_key = '_social_broadcasted_ids'\n\t\tORDER BY post_id DESC\n\t\tLIMIT 50\n\t");
 if ($results !== null) {
     $queue = Social_Aggregation_Queue::factory();
     foreach ($results as $result) {
         if (!$queue->find($result->post_id)) {
             $queue->add($result->post_id);
         }
     }
     $queue->save();
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:31,代码来源:2.0.php

示例15: deauthorized

 /**
  * Checks to see if the broadcasting account has been deauthorized.
  *
  * @param  bool  $check_invalid_key
  * @return bool
  */
 public function deauthorized($check_invalid_key = FALSE)
 {
     $body = $this->body();
     if (isset($body->result) and $body->result == 'error' and isset($body->response) and $this->_service->deauthorized($body->response, $check_invalid_key)) {
         if ($this->_account->personal()) {
             $url = Social::settings_url(array(), true);
         } else {
             $url = Social::settings_url();
         }
         $deauthorized = get_option('social_deauthorized', array());
         if (!isset($deauthorized[$this->_service->key()])) {
             $deauthorized[$this->_service->key()] = array();
         }
         $deauthorized[$this->_service->key()][$this->_account->id()] = sprintf(__('Unable to publish to %s with account %s. Please <a href="%">re-authorize</a> this account.', 'social'), esc_html($this->_service->title()), esc_html($this->_account->name()), esc_url($url));
         update_option('social_deauthorized', $deauthorized);
         Social::log('Removing deauthorized account: :account', array('account' => print_r($this->_account)));
         $this->_service->remove_account($this->_account)->save();
         return true;
     }
     return false;
 }
开发者ID:Blueprint-Marketing,项目名称:interoccupy.net,代码行数:27,代码来源:response.php


注:本文中的Social::log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。