Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of the WordPress Weibo Wall plug-in based on Yar

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the Yar-based WordPress Weibo wall plug-in what is useful, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to know about it.

WordPress Weibo Wall plug-in based on Yar

In the current era of mobile Internet, Weibo has become an indispensable social tool in everyone's life. While WordPress is the most popular blog system in the world, connecting your blog to Sina Weibo, with the help of the strong user base of Weibo, can not only provide huge traffic to your site, but also bring inestimable value.

WordPress Weibo Wall is such a tool, this is not an ordinary plug-in, this is a built in SAE Yar-based plug-in. It is very lightweight, unlike other plug-ins, it provides a lot of gorgeous but impractical features, not only bloated but also slow down. This is a plug-in based on Yar, the underlying C language development, excellent performance. And it is very expandable, which can provide you with the following functions:

1. Personal Weibo wall

two。 Post articles synchronized to Sina Weibo

3. Article comments are synchronized to Sina Weibo

Next, let's introduce the basic structure:

1 core data operation class

This class is in the Dao.class.php file, which is the core of the plug-in and is responsible for getting data from the server.

/ * author data acquisition class * @ author summer * @ date June 28th, 2015 * @ site http://www.xtwind.com**/class Dao {/ * Weibo RPC operator * / private $client; / * user ID * / private $mark / * Constructor sets user ID * / function _ _ construct ($state); / * * returns user ID * / public function getMark () / * * enable plug-in * @ return successfully returned true, failed to return authentication address * / public function run (); / * * obtain authorization * @ return string returned expiration time, not logged in or expired returned false * / public function getAuthOver () / * Delete authorization * @ return boolean * / public function delAuth (); / * obtain authentication jump url * @ return string * / public function getAuthUrl () / * get user Weibo list * @ return array * / public function getWeibo (); / * get basic user information * @ return array * / public function getUser () / * publish Weibo * @ return Array returns Weibo data array * / public function weiboPub ($content,$imgUrl=null) / * delete Weibo * @ param int Weibo ID * @ return Array returns the deleted Weibo data array * / public function weiboDel ($weiboID) / * posted a comment * @ param int Weibo ID * @ param string comment content * @ return array comment related array * / public function sendComment ($id,$comment) / * follow a user * @ param user ID or name * @ return return follower information * / public function followUser ($user) / * forward the content added by Weibo * @ param int Weibo id * @ param string * / public function forwardWeibo ($id,$text=null);} 2 plug-in entity class

This class is the entity of the plug-in, defined in Plugins.class.php, and is responsible for calling the Dao class to implement various functions, including input and output, user configuration, and authorization management.

/ * * plug-in entity class * @ Author:Summer* @ data: 2015-06-28 * @ site: http://www.xtwind.com*/class Plugins {/ * data acquisition class object * / private $dao / * * plug-in display alias * / private $slug = 'weibo-wall'; / * plug-in page url * / private $plugUrl; / * plug-in construction * @ param user data manipulation class * / public function _ _ construct (Dao $obj) / * enable plug-ins, register hooks, call user functions, delete authorization, publish Weibo * @ param array plug-in settings option association array. Key must be the corresponding operation method. The keys in this array will be registered as actions to be filtered by wordpress corresponding hooks * @ param array. Keys in this array will not be registered as hooks, but will be called as methods. The value is the parameter of the method * / public function run ($arr1=null,$arr2=null) / * * the plug-in home page shows * / public function display_function (); / * New articles are released synchronously on Weibo * @ param int articles ID * / public function publish_post ($postID) / * Delete articles synchronously delete Weibo * @ param int posts ID * / public function before_delete_post ($postID); / * receive comments synchronized to Weibo comments * @ param id comments id * / public function comment_post ($commentID) / * * follow author * / public function follow_author ($userid); / * * user Weibo data acquisition * / public function weiboOuput ($atts=null, $content = null); / * * data page output * / public function showWeibo () / * * Image URL processing * @ param string * / private function getOriginalUrl ($url); / * time conversion * @ param string * / private function Sec2Time ($time) / * * the plug-in sets key to get the key * / private function setting_key ($key,$func=false) that * @ param string needs to set; / * * the plug-in sets the value to get the value * / private function get_setting ($key,$func=false) that * @ param string needs to get / * plugin settings delete * / private function del_setting (); / * prompt * @ param string * / private function noticeMsg ($msg);} 3 server authentication operation

This interface defines all the actions required for user authentication, including obtaining authorization, deleting authorization, checking authorization, etc., and defining it in AuthDao.php

/ * author summer * @ date June 18, 2015 * @ site http://www.xtwind.com*/interface AuthDao {/ * set user AccessToken * @ return boolean * / public function setAccessToken () / * get the user AccessToken * @ return String * / public function getAccessToken (); / * delete the user AccessToken * @ return boolean * / public function delAccessToken () / * determine whether user AccessToken exists * @ return boolean * / public function isLogin (); / * * obtain authentication and jump to url * @ return string * / public function getAuthUrl () / * * Authorization Expiration time * @ return string * / public function getAuthOver ();} 4 Server Weibo operation

This interface defines all the methods related to the user's Weibo operation, including publishing Weibo, reading Weibo, reading information, deleting Weibo, etc., in the WeiboDao.php definition

/ * * Weibo operation interface * @ author summer * @ date June 18, 2015 * @ site http://www.xtwind.com*/interface WeiboDao {/ * get user Weibo information list * @ param int get quantity * @ param int type filter 0: all, 1: original, 2: pictures, 3: video, 4: music The default is 0. * @ return String * / public function getWeibo (); / * * get basic user information * @ return Array * / public function getUser () / * publish Weibo * @ return Array return Weibo data array * / public function weiboPub ($content,$imgUrl); / * delete Weibo * @ return Array return deleted Weibo data array * / public function weiboDel ($weiboID) / * post a comment * @ param integer Weibo ID * @ param string comment content * / public function sendComment ($id,$comment) / * follow a user * @ param user ID or name * @ return return follower information * / public function followUser ($user) / * forward the information added by Weibo * @ param int Weibo id * @ param string * / public function forwardWeibo ($id,$text=null);} 5 server data provision API

This interface is responsible for providing data to the client and some operations required by the client. It inherits from the Weibo operation interface and is defined in APIDao.php.

/ * provides service APIs, inherited from the Weibo API * @ author Summer * @ date June 18, 2015 * @ site http://www.xtwind.com*/interface DaoAPI extends WeiboDao {/ * Delete user AccessToken * @ return boolean * / public function delAccessToken () / * determine whether user AccessToken exists * @ return boolean * / public function isLogin (); / * * obtain authentication and jump to url * @ return string * / public function getAuthUrl () / * * Authorization expiration time * @ return string * / public function getAuthOver ();} 6 server callback operation

This class encapsulates the callback operation after communicating with the Weibo open platform to obtain the user's AccessToken

Class Callback {/ * Weibo authentication class object * / private $authObj; / * constructor * @ param AuthDaoImpl Weibo authentication object * / public function _ _ construct (AuthDaoImpl $obj) / * Authentication callback operation, save AccessToken * @ return boolean * / public function callback ();} 7 server application entry

The main purpose of this entry is to distribute callback requests and create RPC instances

If ($_ GET ['code']) {$keys = array (' code' = > $_ GET ['code'],' redirect_uri' = > APP_CALLBACK); $back = new Callback (new AuthDaoImpl ($_ GET ['state'], $keys)) If ($back- > callback ()) {header ('Location:'. $_ GET ['state']. / wp-admin/options-general.php?page=weibo-wall');} exit;} if ($_ GET [' user']) {$server = new Yar_Server (new API ($_ GET ['user'])); try {$server- > handle () } catch (Exception $e) {echo "Thank you for using Weibo Wall!" ;}} 7 client application entry

The entry instantiates the plug-in entity class and enables the plug-in

$plu = new Plugins (new Dao (get_bloginfo ('url'); $plu-> run (get_option (' weibo_wall'), get_option ('weibo_func')); Thank you for reading this article carefully. I hope the article "what is the use of the WordPress Weibo Wall plug-in based on Yar" shared by the editor will be helpful to you. At the same time, I also hope you will support us, pay attention to the industry information channel, and more related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report