Typecho 新浪登陆插件 Sinauth

简介: 花了点时间弄了一个插件。代码地址:https://github.com/web3d/plugins/tree/master/SinauthTypecho的扩展机制还是比较完善的,可以自行增加Action、Route、扩展现有Widget功能、后台插件配置界面等。

花了点时间弄了一个插件。

代码地址:https://github.com/web3d/plugins/tree/master/Sinauth

Typecho的扩展机制还是比较完善的,可以自行增加Action、Route、扩展现有Widget功能、后台插件配置界面等。

偷懒,使用的是SAE中封装的sdk访问新浪开放平台数据。

插件放到/root_path/usr/plugins/Sinauth 目录下:

Plugin.php
AuthorizeAction.php

Plugin.php用于插件初始化,AuthorizeAction.php用于扩展功能。

<?php
class Sinauth_Plugin implements Typecho_Plugin_Interface
{
    /**
     * 激活插件方法,如果激活失败,直接抛出异常
     * 
     * @access public
     * @return void
     * @throws Typecho_Plugin_Exception
     */
    public static function activate()
    {
        Typecho_Plugin::factory('Widget_User')->___sinauthAuthorizeIcon = array('Sinauth_Plugin', 'authorizeIcon');
        
        Helper::addAction('sinauthAuthorize', 'Sinauth_AuthorizeAction');
        Helper::addRoute('sinauthAuthorize', '/sinauthAuthorize/', 'Sinauth_AuthorizeAction', 'action');
        Helper::addRoute('sinauthCallback', '/sinauthCallback/', 'Sinauth_AuthorizeAction', 'callback');
        
        return _t($meg.'。请进行<a href="options-plugin.php?config='.self::$pluginName.'">初始化设置</a>');
    }
    
    public static function install()
    {
       //db创建
    }

    /**
     * 获取插件配置面板
     * 
     * @access public
     * @param Typecho_Widget_Helper_Form $form 配置面板
     * @return void
     */
    public static function config(Typecho_Widget_Helper_Form $form)
    {
        $client_id = new Typecho_Widget_Helper_Form_Element_Text('client_id', NULL,'', _t('App Key'),'请在微博开放平台查看http://open.weibo.com');
        $form->addInput($client_id);
        
        $client_secret = new Typecho_Widget_Helper_Form_Element_Text('client_secret', NULL,'', _t('App Secret'),'请在微博开放平台查看http://open.weibo.com');
        $form->addInput($client_secret);
        
        $callback_url = new Typecho_Widget_Helper_Form_Element_Text('callback_url', NULL,'http://', _t('回调地址'),'请与微博开放平台中设置一致');
        $form->addInput($callback_url);
        
    }
}
class Sinauth_AuthorizeAction extends Typecho_Widget implements Widget_Interface_Do
{
    public function action(){
        
    }

    public function callback(){
        
    }
}

在需要放入口的地方,加上

<?php $this->user->sinauthAuthorizeIcon(); ?>
目录
相关文章
|
4天前
|
存储 API PHP
兰空图床Typecho上传插件LskyPluginTypechoV2安装及使用教程
【10月更文挑战第1天】本插件基于isYangs、泽泽站长、兔子君、冷寂等前辈的作品,适用于Typecho。教程包括获取API Token、设置插件及上传图片等步骤。
18 0
|
2月前
|
缓存
Typecho——非插件方式实现QQ和Gravatar缓存到本地
Typecho——非插件方式实现QQ和Gravatar缓存到本地
44 0
|
2月前
|
应用服务中间件 nginx
typecho——typecho如何开启伪静态
typecho——typecho如何开启伪静态
40 0
|
4月前
|
缓存
discuz X3.* 手机版门户伪静态
discuz X3.* 手机版门户伪静态
43 0
|
Web App开发 缓存 数据安全/隐私保护
phpcms服务器搭建之 phpcms网站基本介绍
phpcms服务器搭建之 phpcms网站基本介绍
115 0
|
关系型数据库 MySQL PHP
PHP注册、登陆、6套主页-带Thinkphp目录解析-【白嫖项目】
PHP注册、登陆、6套主页-带Thinkphp目录解析-【白嫖项目】 CSDN 转过来的,所以格式与内容有些许错误请见谅
|
前端开发
Typecho打赏功能
最近逛了好多博客,发现大家的文章底下都有一个共同特点 文章页面底下都有一个打赏(要饭)的按钮 回到我的博客一看发现没有,这可不得行 于是我也整了一个,顺便分享给大家
99 0
Typecho打赏功能
|
数据库 数据库管理
搭建 Zblog 博客系统-4
搭建 Zblog 博客系统-4
132 0
搭建 Zblog 博客系统-4
|
机器学习/深度学习 JavaScript 搜索推荐