国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

Typecho 新浪登陸插件 Sinauth

2019-11-15 02:15:06
字體:
供稿:網(wǎng)友
Typecho 新浪登陸插件 Sinauth

花了點時間弄了一個插件。

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

Typecho的擴展機制還是比較完善的,可以自行增加Action、Route、擴展現(xiàn)有Widget功能、后臺插件配置界面等。

偷懶,使用的是SAE中封裝的sdk訪問新浪開放平臺數(shù)據(jù)。

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

Plugin.phpAuthorizeAction.php

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

<?phpclass 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.'">初始化設(shè)置</a>');    }        public static function install()    {       //db創(chuàng)建    }    /**     * 獲取插件配置面板     *      * @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('回調(diào)地址'),'請與微博開放平臺中設(shè)置一致');        $form->addInput($callback_url);            }}
class Sinauth_AuthorizeAction extends Typecho_Widget implements Widget_Interface_Do{    public function action(){            }    public function callback(){            }}

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

<?php $this->user->sinauthAuthorizeIcon(); ?>

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 桐庐县| 淄博市| 将乐县| 基隆市| 班玛县| 张家港市| 南开区| 武功县| 明水县| 平舆县| 美姑县| 大姚县| 汉中市| 东台市| 临颍县| 万源市| 岑溪市| 乡宁县| 巩留县| 大荔县| 尚志市| 广宁县| 郎溪县| 安顺市| 报价| 汝州市| 平塘县| 洛扎县| 苗栗市| 庐江县| 三门县| 五峰| 马鞍山市| 富源县| 舞钢市| 甘谷县| 留坝县| 上犹县| 铁岭县| 庆云县| 庆云县|