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


PHP Foreign_link::set_flags方法代码示例

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


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

示例1: saveForeignLink

 /**
  * Saves a Foreign_link between Twitter user and local user,
  * which includes the access token and secret.
  *
  * @param int        $user_id StatusNet user ID
  * @param int        $twuid   Twitter user ID
  * @param OAuthToken $token   the access token to save
  *
  * @return nothing
  */
 function saveForeignLink($user_id, $twuid, $access_token)
 {
     $flink = new Foreign_link();
     $flink->user_id = $user_id;
     $flink->service = TWITTER_SERVICE;
     // delete stale flink, if any
     $result = $flink->find(true);
     if (!empty($result)) {
         $flink->safeDelete();
     }
     $flink->user_id = $user_id;
     $flink->foreign_id = $twuid;
     $flink->service = TWITTER_SERVICE;
     $creds = TwitterOAuthClient::packToken($access_token);
     $flink->credentials = $creds;
     $flink->created = common_sql_now();
     // Defaults: noticesync on, everything else off
     $flink->set_flags(true, false, false, false);
     $flink_id = $flink->insert();
     if (empty($flink_id)) {
         common_log_db_error($flink, 'INSERT', __FILE__);
         // TRANS: Server error displayed when linking to a Twitter account fails.
         $this->serverError(_m('Could not link your Twitter account.'));
     }
     return $flink_id;
 }
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:36,代码来源:twitterauthorization.php

示例2: addTwitterAccount

 /**
  * Associate a Twitter account with the user's account
  *
  * Validates post input; verifies it against Twitter; and if
  * successful stores in the database.
  *
  * @return void
  */
 function addTwitterAccount()
 {
     $screen_name = $this->trimmed('twitter_username');
     $password = $this->trimmed('twitter_password');
     $noticesync = $this->boolean('noticesync');
     $replysync = $this->boolean('replysync');
     $friendsync = $this->boolean('friendsync');
     if (!Validate::string($screen_name, array('min_length' => 1, 'max_length' => 15, 'format' => VALIDATE_NUM . VALIDATE_ALPHA . '_'))) {
         $this->showForm(_('Username must have only numbers, ' . 'upper- and lowercase letters, ' . 'and underscore (_). 15 chars max.'));
         return;
     }
     if (!$this->verifyCredentials($screen_name, $password)) {
         $this->showForm(_('Could not verify your Twitter credentials!'));
         return;
     }
     $twit_user = twitter_user_info($screen_name, $password);
     if (!$twit_user) {
         $this->showForm(sprintf(_('Unable to retrieve account information ' . 'For "%s" from Twitter.'), $screen_name));
         return;
     }
     if (!save_twitter_user($twit_user->id, $screen_name)) {
         $this->showForm(_('Unable to save your Twitter settings!'));
         return;
     }
     $user = common_current_user();
     $flink = new Foreign_link();
     $flink->user_id = $user->id;
     $flink->foreign_id = $twit_user->id;
     $flink->service = TWITTER_SERVICE;
     $flink->credentials = $password;
     $flink->created = common_sql_now();
     $flink->set_flags($noticesync, $replysync, $friendsync);
     $flink_id = $flink->insert();
     if (!$flink_id) {
         common_log_db_error($flink, 'INSERT', __FILE__);
         $this->showForm(_('Unable to save your Twitter settings!'));
         return;
     }
     if ($friendsync) {
         save_twitter_friends($user, $twit_user->id, $screen_name, $password);
     }
     $this->showForm(_('Twitter settings saved.'), true);
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:51,代码来源:twittersettings.php


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