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


PHP url::getShortUrl方法代码示例

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


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

示例1: bulid_hyperlinks

 private function bulid_hyperlinks($matches)
 {
     $notlink = false;
     $matches[0] = str_replace("&", "&", $matches[0]);
     if (stripos($matches[0], YOURLS_SITE) !== false) {
         $shortUrl = $matches[0];
     } else {
         $shortUrl = url::getShortUrl($matches[0]);
     }
     return $shortUrl;
 }
开发者ID:momoim,项目名称:momo-api,代码行数:11,代码来源:comment.php

示例2: bulid_hyperlinks

 private function bulid_hyperlinks($matches)
 {
     $matchUrl = str_replace('&', '&', $matches[0]);
     $tmp = preg_split("/(&#039|&quot)/", $matchUrl);
     $debris = isset($tmp[1]) ? substr($matchUrl, strlen($tmp[0])) : "";
     $matchUrl = $tmp[0];
     if (stripos($matchUrl, YOURLS_SITE) !== false) {
         $shortUrl = $matchUrl;
     } else {
         $shortUrl = strlen($matchUrl) <= 18 ? $matchUrl : url::getShortUrl($matchUrl);
     }
     return "<a href=\"{$shortUrl}\" target=\"_blank\">{$shortUrl}</a>{$debris}";
 }
开发者ID:momoim,项目名称:momo-api,代码行数:13,代码来源:life.php

示例3: invite

 /**
  * 
  * 活动邀请
  */
 public function invite($id = NULL)
 {
     if ($this->get_method() != 'POST') {
         $this->send_response(405, NULL, '请求的方法不存在');
     }
     if (empty($id)) {
         $this->send_response(400, NULL, '400501:活动ID为空');
     }
     $data = $this->get_data();
     if (!$data) {
         $this->send_response(400, NULL, '400412:活动信息非法');
     }
     $event_info = $this->model->get($id);
     if (!$event_info) {
         $this->send_response(400, NULL, '400506:活动不存在');
     }
     if (empty($data['user'])) {
         $this->send_response(400, NULL, '400508:活动报名信息为空');
     }
     $return = array();
     $update_apply_type = false;
     $post = new Validation($data);
     $post->add_rules('user', 'required');
     $post->add_callbacks(TRUE, array($this, '_check_user_validation'));
     if ($post->validate()) {
         $form = $post->as_array();
         if (count($form['user'] > 0)) {
             $user_array = $this->_get_event_uid($form['user']);
             $i = 0;
             $cover = Event_Image_Model::instance()->getCover($id);
             $cover = $cover ? $cover : '';
             $opt = array('event' => array('id' => $id, 'name' => $event_info['title'], 'cover' => $cover), 'no_sign' => 1);
             foreach ($user_array as $mobile => $user) {
                 $i++;
                 if ($this->user_id == $user['user_id'] || empty($user['user_id'])) {
                     continue;
                 }
                 $apply_type = $this->model->getApplyType(array('eid' => $id, 'uid' => $user['user_id']));
                 if (!$apply_type || $apply_type == Kohana::config('event.apply_type.refused')) {
                     if ($apply_type == Kohana::config('event.apply_type.refused')) {
                         $update_apply_type = true;
                     }
                     $eventUser = array('eid' => $id, 'pid' => 0, 'uid' => $user['user_id'], 'name' => $user['name'], 'mobile' => $mobile, 'apply_type' => Kohana::config('event.apply_type.unconfirmed'), 'apply_time' => time(), 'invite_by' => $this->user_id, 'grade' => Kohana::config('event.grade.normal'));
                     $this->model->applyEvent($eventUser, $update_apply_type);
                 }
                 if (!in_array($apply_type, array(Kohana::config('event.apply_type.joined'), Kohana::config('event.apply_type.interested')))) {
                     $return[] = array('uid' => $user['user_id'], 'name' => $user['name'], 'mobile' => $mobile, 'avatar' => sns::getAvatar($user['user_id']));
                     $device_id = md5($mobile . '_' . '0');
                     $token = User_Model::instance()->request_access_token(0, $user['user_id'], $device_id, Kohana::config('event.appid'));
                     $event_url = MO_EVENT . 'event/show/' . $id . '?token=' . $token['oauth_token'];
                     $event_short_url = url::getShortUrl($event_url);
                     $content = '邀请你参加活动:' . $event_short_url;
                     $this->send_event_mq($this->user_id, $user['user_id'], $content, $opt);
                 } else {
                     $this->send_response(400, NULL, '400511:该用户已报名');
                 }
             }
             $this->send_response(200, array('num' => $i, 'user' => $return));
         }
     }
     $errors = $post->errors();
     foreach ($errors as $key => $value) {
         switch ($key) {
             case 'user_name_empty':
                 $this->send_response(400, NULL, '400502:名字为空');
                 break;
             case 'user_mobile_empty':
                 $this->send_response(400, NULL, '400503:手机号为空');
                 break;
             case 'user_mobile_format':
                 $this->send_response(400, NULL, '400504:手机号格式不正确');
                 break;
         }
     }
 }
开发者ID:momoim,项目名称:momo-api,代码行数:79,代码来源:event.php


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