示例#1
0
function open_denglu_cc($token, $muid)
{
    global $wptm_basic;
    if (!$wptm_basic) {
        $version = this_version();
        $content = array();
        $content['sitename'] = get_bloginfo('name');
        $content['siteurl'] = get_bloginfo('wpurl') . '/';
        if ($version == 5) {
            // 全新安装
            $keys = array(array('mediaID' => 3, 'apikey' => '1624795996', 'appsecret' => '7ecad0335a50c49a88939149e74ccf81'), array('mediaID' => 4, 'apikey' => 'd05d3c9c3d3748b09f231ef6d991d3ac', 'appsecret' => 'e049e5a4c656a76206e55c91b96805e8'));
            $content['keys'] = $keys;
        } elseif ($version == 3) {
            // 旧版升级
            $content['keys'] = open_appkey();
        }
        $content = json_encode($content);
        // return var_dump($content);
        class_exists('Denglu') or (require dirname(__FILE__) . "/class/Denglu.php");
        $api = new Denglu('', '', 'utf-8');
        try {
            // 写到denglu.cc服务器(网站名称、网站网址、token、mediaUserID,并返回数据,包括app id、 app key
            $ret = $api->register($token, $muid, $content);
        } catch (DengluException $e) {
            // 获取异常后的处理办法(请自定义)
            // return false;
            wp_die($e->geterrorDescription());
            //返回错误信息
        }
        // return var_dump($ret);
        if ($ret['appid']) {
            update_option("wptm_basic", array('appid' => $ret['appid'], 'appkey' => $ret['apikey'], 'denglu' => 1));
        }
    }
}