コード例 #1
0
ファイル: account.php プロジェクト: nick5a1/wp-social
 /**
  * Gets the username of the account.
  *
  * @return string
  */
 public function username()
 {
     if ($this->has_user()) {
         return $this->_user->screen_name;
     }
     return parent::_username();
 }
コード例 #2
0
 /**
  * Sets the raw data for the broadcasted post.
  *
  * @wp-filter social_broadcast_response
  * @static
  * @param  array                   $data
  * @param  Social_Service_Account  $account
  * @param  string                  $service_key
  * @param  int                     $post_id
  * @param  Social_Response         $response
  * @return array
  */
 public static function social_save_broadcasted_ids_data(array $data, Social_Service_Account $account, $service_key, $post_id, Social_Response $response = null)
 {
     if ($service_key == 'facebook') {
         $broadcast_page = $account->broadcast_page();
         if ($broadcast_page !== null) {
             $data['page'] = (object) array('id' => $broadcast_page->id, 'name' => $broadcast_page->name);
         }
         $data['account'] = (object) array('user' => $account->as_object()->user);
     }
     return $data;
 }
コード例 #3
0
 /**
  * Loads the pages for the account.
  *
  * @param  Social_Service_Account  $account
  * @param  bool                    $is_profile
  * @param  bool                    $save
  * @return array
  */
 public function get_pages(Social_Service_Account $account, $is_profile = false, $save = true)
 {
     $pages = array();
     if ($account->use_pages() or $account->use_pages(true)) {
         $response = $this->request($account, $account->id() . '/accounts');
         if ($response !== false and isset($response->body()->response)) {
             if (isset($response->body()->response->data)) {
                 foreach ($response->body()->response->data as $item) {
                     if ($item->category != 'Application') {
                         $pages[$item->id] = $item;
                     }
                 }
             } else {
                 if ($response->body()->response == 'incorrect method') {
                     // Account no longer has page permissions.
                     $service = Social::instance()->service('facebook');
                     $accounts = $service->accounts();
                     foreach ($accounts as $account_id => $_account) {
                         if ($account_id == $account->id()) {
                             $_account->use_pages(false, false);
                             $_account->use_pages(true, false);
                             $_account->pages(array(), $is_profile);
                         }
                         $accounts[$account_id] = $account->as_object();
                     }
                     if ($save) {
                         $service->accounts($accounts)->save($is_profile);
                     }
                 }
             }
         }
     }
     return $pages;
 }
コード例 #4
0
ファイル: social.php プロジェクト: sekane81/ratoninquietoweb
 /**
  * Sets the broadcasted IDs for the post.
  *
  * @param  int  $post_id  post id
  * @param  string  $service  service key
  * @param  string  $broadcasted_id  broadcasted id
  * @param  string  $message  broadcasted message
  * @param  Social_Service_Account  $account  account
  * @param  Social_Response  $response  response object
  * @return void
  */
 public function add_broadcasted_id($post_id, $service, $broadcasted_id, $message, $account, Social_Response $response = null)
 {
     $broadcasted_ids = get_post_meta($post_id, '_social_broadcasted_ids', true);
     if (empty($broadcasted_ids)) {
         $broadcasted_ids = array();
     }
     if (!isset($broadcasted_ids[$service])) {
         $broadcasted_ids[$service] = array();
     }
     if (!isset($broadcasted_ids[$service][$account->id()])) {
         $broadcasted_ids[$service][$account->id()] = array();
     }
     if (!isset($broadcasted_ids[$service][$account->id()][$broadcasted_id])) {
         $urls = array(get_permalink($post_id));
         $shortlink = social_get_shortlink($post_id);
         if (!in_array($shortlink, $urls)) {
             $urls[] = $shortlink;
         }
         $home_url = home_url('?p=' . $post_id);
         if (!in_array($home_url, $urls)) {
             $urls[] = $home_url;
         }
         $data = array('message' => $message, 'urls' => $urls);
         $data = apply_filters('social_save_broadcasted_ids_data', $data, $account, $service, $post_id, $response);
         $broadcasted_ids[$service][$account->id()][$broadcasted_id] = $data;
         update_post_meta($post_id, '_social_broadcasted_ids', $broadcasted_ids);
     }
 }
コード例 #5
0
ファイル: account.php プロジェクト: nick5a1/wp-social
 /**
  * Gets the username of the account.
  *
  * @return string
  */
 public function username()
 {
     if ($this->has_user()) {
         if (!isset($this->_user->username)) {
             $this->_user->username = $this->_user->name . '.' . $this->_user->id;
         }
         return $this->_user->username;
     }
     return parent::_username();
 }
コード例 #6
0
ファイル: service.php プロジェクト: nick5a1/wp-social
 /**
  * Gets the requested account.
  *
  * @param  int|Social_Service_Account  $account  account id/object
  * @return Social_Service_Account|Social_Service|bool
  */
 public function account($account)
 {
     if ($account instanceof Social_Service_Account) {
         $this->_accounts[$account->id()] = $account;
         return $this;
     }
     if ($this->account_exists($account)) {
         return $this->_accounts[$account];
     }
     return false;
 }
コード例 #7
0
ファイル: social-twitter.php プロジェクト: nick5a1/wp-social
 /**
  * Sets the raw data for the broadcasted post.
  *
  * @wp-filter social_broadcast_response
  * @static
  * @param  array                   $data
  * @param  Social_Service_Account  $account
  * @param  string                  $service_key
  * @param  int                     $post_id
  * @param  Social_Response         $response
  * @return array
  */
 public static function social_save_broadcasted_ids_data(array $data, Social_Service_Account $account, $service_key, $post_id, Social_Response $response = null)
 {
     if ($service_key == 'twitter') {
         if (!empty($response)) {
             $data['message'] = base64_encode(json_encode($response->body()->response));
         }
         $data['account'] = (object) array('user' => $account->as_object()->user);
     }
     return $data;
 }