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


PHP Error::isError方法代码示例

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


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

示例1: getIp

 public static function getIp()
 {
     $accessToken = AccessToken::getAccessToken();
     $url = 'https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=' . $accessToken;
     $res = Curl::httpGet($url);
     return Error::isError($res) ? false : $res['ip_list'];
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:7,代码来源:WechatIp.class.php

示例2: getTemplateId

 public static function getTemplateId($template_id_short)
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/template/api_add_template?access_token=' . AccessToken::getAccessToken();
     $data = array('template_id_short' => $template_id_short);
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res['template_id'];
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:7,代码来源:Template.class.php

示例3: uploadNews

 public static function uploadNews($articles)
 {
     /* 传入data实例
        $articles[] = array(
            'thumb_media_id'=> $media_id,
            'author'=> '天王盖地虎',
            'title'=> '这个我的测试消息',
            'content_source_url'=> 'our-class.cn',
            'content'=> '这是一个图文摘要',
            'digest'=> '',
            'show_cover_pic'=> 1,
        );
        $articles[] = array(
            'thumb_media_id'=> $media_id,
            'author'=> '天王盖地虎',
            'title'=> '这个我的测试消息',
            'content_source_url'=> 'our-class.cn',
            'content'=> '这是一个图文摘要',
            'digest'=> '',
            'show_cover_pic'=> 1,
        );
        */
     $url = 'https://api.weixin.qq.com/cgi-bin/media/uploadnews?access_token=' . AccessToken::getAccessToken();
     if (count($articles) > 10) {
         href('文章总数大于10');
         return false;
     }
     $data = array('articles' => $articles);
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res['media_id'];
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:31,代码来源:Media.class.php

示例4: long2short

 public static function long2short($url)
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/shorturl?access_token=' . AccessToken::getAccessToken();
     $data = array('action' => 'long2short', 'long_url' => $url);
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res['short_url'];
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:7,代码来源:Popularize.class.php

示例5: getuser

 static function getuser($begin_date, $end_date, $summary = true)
 {
     if ($summary) {
         $url = 'https://api.weixin.qq.com/datacube/getusersummary?access_token=' . AccessToken::getAccessToken();
     } else {
         $url = 'https://api.weixin.qq.com/datacube/getusercumulate?access_token=' . AccessToken::getAccessToken();
     }
     $data = array('begin_date' => $begin_date, 'end_date' => $end_date);
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res;
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:11,代码来源:Statistics.class.php

示例6: setImage

 public static function setImage($file, $kf_account)
 {
     if (!file_exists($file)) {
         href('文件不存在');
         return false;
     }
     $url = 'http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=' . AccessToken::getAccessToken() . '&kf_account=' . $kf_account;
     $data = array('filename' => $file);
     $data = array("media" => "@" . $file, 'form-data' => $data);
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res;
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:12,代码来源:CustomerServices.class.php

示例7: addMedia

 public static function addMedia($file, $type = 'image', $info = array())
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=' . AccessToken::getAccessToken();
     if (!file_exists($file)) {
         href('文件不存在');
         exit;
     }
     $data = array('filename' => $file);
     if ($type == 'video') {
         $description = array('title' => $info['title'], 'introduction' => $info['introduction']);
         $data = array("media" => "@" . $file, 'form-data' => $data, 'type' => $type, 'description' => $description);
     } else {
         $data = array("media" => "@" . $file, 'form-data' => $data, 'type' => $type);
     }
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res;
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:17,代码来源:Material.class.php

示例8: getJsApiTicket

 private static function getJsApiTicket()
 {
     $mmc = memcache_init();
     $ticketInfo = @$mmc->get('ticket');
     if (isset($ticketInfo['ticket']) && time() - $ticketInfo['expires'] < 7000) {
         return $ticketInfo['ticket'];
     }
     $url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?type=jsapi&access_token=" . AccessToken::getAccessToken();
     $res = Curl::httpGet($url);
     if (Error::isError($res)) {
         exit;
     }
     $data['ticket'] = $res['ticket'];
     $data['expires'] = time();
     //存入Memcache
     $mmc->set('ticket', $data, 7200);
     return $res['ticket'];
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:18,代码来源:JSSDK.class.php

示例9: getAccessToken

 public static function getAccessToken()
 {
     $mmc = memcache_init();
     $accessTokenArr = @$mmc->get('accessToken');
     $accessToken = $accessTokenArr['access_token'];
     if (!isset($accessTokenArr['access_token']) || time() - $accessTokenArr['expires'] > 7200 - 100) {
         $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&' . 'appid=' . getConfig('WX')['appID'] . '&secret=' . getConfig('WX')['appsecret'];
         $res = Curl::httpGet($url);
         if (Error::isError($res)) {
             return false;
         }
         $res['expires'] = time();
         //存入Memcache
         $mmc->set('accessToken', $res, 7200);
         $accessToken = $res['access_token'];
     }
     return $accessToken;
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:18,代码来源:AccessToken.class.php

示例10: getContent

    public function getContent()
    {
        global $sql;
        if (!LOGGED) {
            return no_access('By mieć dostęp do edycji profilu musisz się zalogować.');
        }
        $note = new Notifier();
        $err = new Error();
        $edit = isset($_POST['edit']) ? true : false;
        $countries = (include 'lang/countries.php');
        asort($countries);
        //Edit user by ID
        if (ctype_digit(u1)) {
            $profile = $sql->query('
				SELECT u.*
				FROM ' . DB_PREFIX . 'users u
				WHERE u.id = ' . u1)->fetch(PDO::FETCH_ASSOC);
            if ($profile) {
                Kio::addTitle(t('Users'));
                Kio::addBreadcrumb(t('Users'), 'users');
                Kio::addTitle($profile['nickname'] . ' - ' . t('Edit profile'));
                Kio::addBreadcrumb($profile['nickname'], 'profile/' . u1);
                Kio::addBreadcrumb(t('Edit profile'), 'edit_profile/' . u1);
                $form = $profile;
            } else {
                return not_found(t('Selected user doesn&apos;t exists.'), array(t('This person was deleted from database.'), t('Entered URL is invalid.')));
            }
        } else {
            $profile = User::toArray();
            Kio::addTitle(t('Edit profile'));
            Kio::addBreadcrumb(t('Edit profile'), 'edit_profile');
        }
        $form = $profile;
        $form['password'] = '';
        $form['password2'] = '';
        $form['birthdate'] = explode('-', $profile['birthdate']);
        $form['newsletter'] = $profile['newsletter'] ? 1 : 0;
        $form['pm_notify'] = $profile['pm_notify'] ? 1 : 0;
        $form['hide_email'] = $profile['hide_email'] ? 1 : 0;
        if (!u1 || $profile) {
            // Edit profile
            if (!empty($edit)) {
                $form = array('nickname' => Kio::getConfig('allow_change_nick', 'edit_profile') ? filter($_POST['nickname'], 100) : User::$nickname, 'password' => filter($_POST['password'], 100), 'password2' => filter($_POST['password2'], 100), 'email' => strtolower(filter($_POST['email'], 100)), 'forename' => $_POST['forename'], 'surname' => $_POST['surname'], 'gender' => $_POST['gender'], 'locality' => $_POST['locality'], 'country' => !empty($countries[$_POST['country']]) ? $_POST['country'] : '', 'communicator' => $_POST['communicator'], 'website' => $_POST['website'], 'birthdate' => array_map('intval', (array) $_POST['birthdate']), 'newsletter' => isset($_POST['newsletter']) ? 1 : 0, 'pm_notify' => isset($_POST['pm_notify']) ? 1 : 0, 'hide_email' => isset($_POST['hide_email']) ? 1 : 0, 'avatar' => $_FILES['avatar']['error'] == 0 && !$_POST['delete_avatar'] ? $_FILES['avatar'] : array(), 'delete_avatar' => isset($_POST['delete_avatar']) ? 1 : 0, 'photo' => isset($_FILES['photo']) ? $_FILES['photo'] : null, 'delete_photo' => isset($_POST['delete_photo']) ? 1 : 0, 'title' => $_POST['title'], 'interests' => $_POST['interests'], 'signature' => $_POST['signature']);
                $allowed_types = array('image/png' => 'png', 'image/jpeg' => 'jpg', 'image/gif' => 'gif');
                // Nickname
                $err->setError('nickname_empty', t('ERROR_NICKNAME_EMPTY'))->condition(!$form['nickname']);
                $err->setError('nickname_exists', t('ERROR_NICKNAME_EXISTS'))->condition(Kio::getConfig('allow_change_nick', 'edit_profile') && $form['nickname'] && strtolower($form['nickname']) != strtolower($profile['nickname']) && is_registered($form['nickname']));
                // Password
                $err->setError('password_differ', t('ERROR_PASSWORD_DIFFER'))->condition($form['password'] != $form['password2']);
                // E-mail
                $err->setError('email_empty', t('ERROR_EMAIL_EMPTY'))->condition(!$form['email']);
                if ($form['email']) {
                    $err->setError('email_invalid', t('ERROR_EMAIL_INVALID'))->condition($form['email'] && !is_email($form['email']));
                    $err->setError('email_exists', t('ERROR_EMAIL_EXISTS'))->condition($form['email'] != $profile['email'] && is_email($form['email']) && is_registered($form['email'], 'email'));
                }
                // Birthdate
                $err->setError('birthdate_invalid', t('ERROR_BIRTHDATE'))->condition(array_sum($form['birthdate']) > 0 && !is_date('Y-n-j', $form['birthdate'][0] . '-' . $form['birthdate'][1] . '-' . $form['birthdate'][2]));
                // Avatar
                if ($form['avatar']) {
                    $err->avatar_invalid_type(t('ERROR_ava'))->condition(!in_array($form['avatar']['type'], array_keys($allowed_types)));
                    $err->avatar_exceeded_max_size(t('ERROR_ava'))->condition(Kio::getConfig('avatar_size_max', 'edit_profile') && !$err->isError('avatar_invalid_type') && $form['avatar']['size'] > Kio::getConfig('avatar_size_max', 'edit_profile'));
                }
                // No errors
                if ($err->noErrors()) {
                    if ($form['delete_avatar']) {
                        unlink(ROOT . 'images/avatars/' . $profile['id'] . '.' . User::$avatar);
                    }
                    if ($form['avatar']) {
                        move_uploaded_file($_FILES['avatar']['tmp_name'], ROOT . 'images/avatars/' . $profile['id'] . '.' . $allowed_types[$form['avatar']['type']]);
                        if ($allowed_types[$form['avatar']['type']] != User::$avatar) {
                            unlink(ROOT . 'images/avatars/' . $profile['id'] . '.' . User::$avatar);
                        }
                    }
                    $form['birthdate'] = array_sum($form['birthdate']) > 0 ? $form['birthdate'][0] . '-' . $form['birthdate'][1] . '-' . $form['birthdate'][2] : '';
                    $sql->exec('
						UPDATE ' . DB_PREFIX . 'users
						SET nickname		= "' . (Kio::getConfig('allow_change_nick', 'edit_profile') ? $form['nickname'] : User::$nickname) . '",
							' . ($form['password'] ? 'pass = "' . md5($form['password']) . '",' : '') . '
							email			= "' . $form['email'] . '",
							forename		= "' . $form['forename'] . '",
							surname			= "' . $form['surname'] . '",
							gender			= ' . ($form['gender'] == 1 || $form['gender'] == 2 ? (int) $form['gender'] : 0) . ',
							locality		= "' . $form['locality'] . '",
							country			= "' . $form['country'] . '",
							communicator	= "' . $form['communicator'] . '",
							website			= "' . $form['website'] . '",
							birthdate		= "' . $form['birthdate'] . '",
							newsletter		= ' . $form['newsletter'] . ',
							pm_notify		= ' . $form['pm_notify'] . ',
							hide_email		= ' . $form['hide_email'] . ',
							' . ($form['avatar'] ? 'avatar = "' . $allowed_types[$form['avatar']['type']] . '",' : ($form['delete_avatar'] ? 'avatar = "",' : '')) . '
							title			= "' . $form['title'] . '",
							interests		= "' . $form['interests'] . '",
							signature		= "' . $form['signature'] . '"
						WHERE id = ' . $profile['id']);
                    $note->success(t('Your profile was modified successfully.'));
                    redirect(HREF . 'edit_profile');
                } else {
                    $note->error($err->toArray());
                }
//.........这里部分代码省略.........
开发者ID:rafalenden,项目名称:KioCMS,代码行数:101,代码来源:edit_profile.module.php

示例11: getUserList

 public static function getUserList($next_openid = NULL)
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/user/get?access_token=' . AccessToken::getAccessToken() . '&next_openid=' . $next_openid;
     $res = Curl::httpGet($url);
     return Error::isError($res) ? false : $res;
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:6,代码来源:UserMange.class.php

示例12: getConfig

 public static function getConfig()
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/get_current_selfmenu_info?access_token=' . AccessToken::getAccessToken();
     $res = Curl::httpGet($url);
     return Error::isError($res) ? false : $res;
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:6,代码来源:Menu.class.php

示例13: doCurl

 private static function doCurl($data)
 {
     self::init();
     $res = Curl::httpGet(self::$url, $data);
     return Error::isError($res) ? false : true;
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:6,代码来源:RequestInitiative.class.php

示例14: preview

 public static function preview($type, $touser, $media_id, $content = NULL)
 {
     $url = 'https://api.weixin.qq.com/cgi-bin/message/mass/preview?access_token=' . AccessToken::getAccessToken();
     switch ($type) {
         case 'text':
             $data = '{
                         "touser":"' . $touser . '",
                         "text":{
                                "content":"' . $content . '"
                                },
                         "msgtype":"text"
                     }';
             break;
         case 'mpnews':
             $data = '{
                        "touser":"' . $touser . '",
                        "mpnews":{
                                 "media_id":"' . $media_id . '"
                                  },
                        "msgtype":"mpnews"
                     }';
             break;
         case 'voice':
             $data = '{
                        "touser":"' . $touser . '",
                        "voice":{
                                 "media_id":"' . $media_id . '"
                                  },
                        "msgtype":"voice"
                     }';
             break;
         case 'image':
             $data = '{
                        "touser":"' . $touser . '",
                        "image":{
                                 "media_id":"' . $media_id . '"
                                  },
                        "msgtype":"image"
                     }';
             break;
         case 'mpvideo':
             $data = '{
                        "touser":"' . $touser . '",
                        "mpvideo":{
                                 "media_id":"' . $media_id . '"
                                  },
                        "msgtype":"mpvideo"
                     }';
             break;
         case 'wxcard':
             $data = '{ "touser":"' . $touser . '",
                       "wxcard":{
                                "card_id":"' . $media_id . '",
                                 "card_ext": "{"code":"","openid":"","timestamp":"1402057159","signature":"017bb17407c8e0058a66d72dcc61632b70f511ad"}"
                                 },
                       "msgtype":"wxcard"
                     }';
             break;
         default:
             href('迷茫了');
             exit;
     }
     $res = Curl::httpGet($url, $data);
     return Error::isError($res) ? false : $res['msg_id'];
 }
开发者ID:lxpfigo,项目名称:blog,代码行数:65,代码来源:Mass.class.php


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