>  기사  >  백엔드 개발  >  Typecho Sina 로그인 플러그인 Sinauth

Typecho Sina 로그인 플러그인 Sinauth

WBOY
WBOY원래의
2016-08-08 09:23:381040검색

플러그인을 구하는 데 시간이 좀 걸렸습니다.

코드 주소: https://github.com/web3d/plugins/tree/master/Sinauth

Typecho의 확장 메커니즘은 비교적 완벽하며 Action, Route 및 확장 기능을 직접 추가할 수 있습니다. 위젯 기능, 백그라운드 플러그인 구성 인터페이스 등이 있습니다.

저는 게을러서 SAE에 패키지된 SDK를 사용하여 Sina Open Platform 데이터에 액세스합니다.

플러그인은 /root_path/usr/plugins/Sinauth 디렉터리에 있습니다.

<code>Plugin.php
AuthorizeAction.php</code>

플러그인 초기화에는 Plugin.php가 사용되고, AuthorizeAction.php는 사용됩니다. 확장된 기능을 위해.

<code><?php
class Sinauth_Plugin implements Typecho_Plugin_Interface
{
    /**
     * 激活插件方法,如果激活失败,直接抛出异常
     * 
     * @access public
     * @return void
     * @throws Typecho_Plugin_Exception
     */
    public static function activate()
    {
        Typecho_Plugin::factory(&#39;Widget_User&#39;)->___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?c/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);
        
    }
}</code>
<code>class Sinauth_AuthorizeAction extends Typecho_Widget implements Widget_Interface_Do
{
    public function action(){
        
    }

    public function callback(){
        
    }
}</code>

입에 넣어야 할 곳에

<code><?php $this->user->sinauthAuthorizeIcon(); ?></code>
를 추가하세요.

위 내용은 Typecho Sina 로그인 플러그인 Sinauth를 소개하고, PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되었으면 좋겠습니다.

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.