Description of Sina Weibo open platform PHP WeiboClient

Source: Internet
Author: User
Tags oauth
After preliminary understanding of the weibo application development process, we recommend that you read the code in weibooauth. php and read the definition of public methods in classWeiboClient first. These methods are used to directly operate Weibo and users. they are clear about the methods, call interfaces, and default parameters. This article provides... "> <LINKhref =" http://www.php100.com//static

After preliminary understanding of the weibo application development process, we recommend that you read the code in weibooauth. php and give priority to the definition of public methods in class WeiboClient. These methods are used to directly operate Weibo and users. they are clear about the methods, call interfaces, and default parameters.

 

This document describes common methods in class WeiboClient. These methods are used to directly operate Weibo and users. they must be skillful in using them and be familiar with the names, parameters, and return value types of each method. Most functions return an array. you also need to use the API documentation to know the information of each field in the corresponding array.

/**
* Posting image Weibo
* @ Access public
* @ Param string $ text the microblog information to be updated.
* @ Param string $ text the path of the image to be published. url is supported. [Only png, jpg, and gif formats are supported. to add a format, modify the get_image_mime method.]
* @ Return array
*/
Function upload ($ text, $ pic_path)

 

Based on this, we know that the code for sending Image Weibo should include:

(1) create an object instance of the WeiboClient class (this instance comes from Authorization, and multiple functions of a program can share one instance );

(2) prepare Weibo information and image URLs;

(3) use the upload method for sending;

(4) Use the returned array to complete subsequent processing.

$ C = new WeiboClient (WB_AKEY,
WB_SKEY,
$ _ SESSION ['last _ key'] ['auth _ token'],
$ _ SESSION ['last _ key'] ['Oss _ token_secret ']);
$ T = 'new Weibo ';
$ P = 'http://ww1.sinaimg.cn/large/67c69b94gw1dqf3w3vct0j.jpg ';
$ Rr = $ c-> upload ($ t, $ p );
Echo"

Sent successfully

";
}
?>

 

 

<? Php $ c = new WeiboClient (WB_AKEY, WB_SKEY, $ _ SESSION ['last _ key'] ['Oss _ token'], $ _ SESSION ['last _ key'] ['oauth _ token_secret ']); $ t = 'new Weibo '; $ p = 'upload $ rr = $ c-> upload ($ t, $ p); echo "<p> Sent successfully </p>" ;}?>
The following describes the public methods in class WeiboClient.

 

Class WeiboClient
{
/**
* Constructor
*
* @ Access public
* @ Param mixed $ akey app key of the Weibo open platform
* @ Param mixed $ skey: SECRET of the Weibo open platform APP
* @ Param mixed $ token returned by accecss_token OAuth
* @ Param mixed $ accecss_token_secret token secret returned by OAuth
* @ Return void
*/
Function _ construct ($ akey, $ skey, $ accecss_token, $ accecss_token_secret)
 
/**
* Latest public Weibo
*
* @ Access public
* @ Return array
*/
Function public_timeline ()
 
/**
* Weibo, the latest followers
*
* @ Access public
* @ Return array
*/
Function friends_timeline ()
 
 
/**
* Weibo, the latest followers
*
* @ Access public
* @ Return array
*/
Function home_timeline ()
 
/**
* Latest @ user's
*
* @ Access public
* @ Param int $ page indicates the page number of the returned result.
* @ Param int $ count the maximum number of records returned each time (that is, the page size). The value is not greater than 200. the default value is 20.
* @ Return array
*/
Function mentions ($ page = 1, $ count = 20)
 
 
/**
* Posting Weibo
*
* @ Access public
* @ Param mixed $ text the microblog information to be updated.
* @ Return array
*/
Function update ($ text)
 

/**
* Posting image Weibo
*
* @ Access public
* @ Param string $ text the microblog information to be updated.
* @ Param string $ text the path of the image to be published. url is supported. [Only png, jpg, and gif formats are supported. to add formats, modify the get_image_mime method.
]
* @ Return array
*/
Function upload ($ text, $ pic_path)
 
 
/**
* Get a single Weibo account
*
* @ Access public
* @ Param mixed $ sid get the ID of the published Weibo account
* @ Return array
*/
Function show_status ($ sid)
 
/**
* Delete Weibo
*
* @ Access public
* @ Param mixed $ ID of the microblog to be deleted by sid
* @ Return array
*/
Function delete ($ sid)
 
 
/**
* Delete Weibo
*
* @ Access public
* @ Param mixed $ ID of the microblog to be deleted by sid
* @ Return array
*/
Function destroy ($ sid)
 
 
/**
* Personal data
*
* @ Access public
* @ Param mixed $ uid_or_name UID or Weibo nickname.
* @ Return array
*/
Function show_user ($ uid_or_name = null)
 
/**
* List of followers
*
* @ Access public
* @ Param bool $ cursor a single page can only contain 100 follow lists. to get more, the cursor starts from-1 by default and is obtained by adding or decreasing cursor.
Retrieve more follow lists
* @ Param bool $ count the maximum number of records returned each time (that is, the page size). The value is not greater than 200. the default value is 20.
* @ Param mixed $ uid_or_name UID or Weibo nickname to be obtained
* @ Return array
*/
Function friends ($ cursor = false, $ count = false, $ uid_or_name = null)
 
 
/**
* Fan list
*
* @ Access public
* @ Param bool $ cursor a single page can only contain a list of 100 fans. to get more, the cursor starts from-1 by default and is obtained by adding or decreasing cursor.
Retrieve more fan lists
* @ Param bool $ count the maximum number of records returned each time (that is, the page size). The value is not greater than 200. the default value is 20.
* @ Param mixed $ uid_or_name UID or Weibo nickname to be obtained
* @ Return array
*/
Function followers ($ cursor = false, $ count = false, $ uid_or_name = null)
 
 
/**
* Follow a user
*
* @ Access public
* @ Param mixed $ uid_or_name user UID or Weibo nickname to be followed
* @ Return array
*/
Function follow ($ uid_or_name)
 
 
/**
* Remove a user from interest
*
* @ Access public
* @ Param mixed $ uid_or_name the UID or Weibo nickname of the user to be followed.
* @ Return array
*/
Function unfollow ($ uid_or_name)
 
 
/**
* Returns the details of the two user relationships.
*
* @ Access public
* @ Param mixed $ uid_or_name user UID to be judged
* @ Return array
*/
Function is_followed ($ uid_or_name)
 
 
/**
* User posting Weibo list
*
* @ Access public
* @ Param int $ page number
* @ Param int $ count the maximum number of records returned each time. a maximum of 200 records can be returned. the default value is 20.
* @ Param mixed $ uid_or_name specifies the UID or Weibo nickname.
* @ Return array
*/
Function user_timeline ($ page = 1, $ count = 20, $ uid_or_name = null)
 
 
/**
* Retrieve the private message list
*
* @ Access public
* @ Param int $ page number
* @ Param int $ count the maximum number of records returned each time. a maximum of 200 records can be returned. the default value is 20.
* @ Return array
*/
Function list_dm ($ page = 1, $ count = 20)
 
 
/**
* List of sent private messages
*
* @ Access public
* @ Param int $ page number
* @ Param int $ count the maximum number of records returned each time. a maximum of 200 records can be returned. the default value is 20.
* @ Return array
*/
Function list_dm_sent ($ page = 1, $ count = 20)
 
 
/**
* Send a private message
*
* @ Access public
* @ Param mixed $ uid_or_name UID or Weibo nickname
* @ Param mixed $ text refers to the message content to be generated. the text size must be less than 300 Chinese characters.
* @ Return array
*/
Function send_dm ($ uid_or_name, $ text)
 
 
/**
* Delete a private message
*
* @ Access public
* @ Param mixed $ did ID of the private key to be deleted
* @ Return array
*/
Function delete_dm ($ did)
 
 
/**
* Forward a Weibo message.
*
* @ Access public
* @ Param mixed $ the Weibo ID forwarded by sid
* @ Param bool $ text the added forwarding information.
* @ Return array
*/
Function repost ($ sid, $ text = false)
 
 
/**
* Comment on a Weibo message
*
* @ Access public
* @ Param mixed $ sid: Weibo id to be commented on
* @ Param mixed $ text comment
* @ Param bool $ cid comment id
* @ Return array
*/
Function send_comment ($ sid, $ text, $ cid = false)
 
 
/**
* Comments
*
* @ Access public
* @ Param int $ page number
* @ Param int $ count the maximum number of records returned each time. a maximum of 200 records can be returned. the default value is 20.
* @ Return array
*/
Function comments_by_me ($ page = 1, $ count = 20)
 
 
/**
* Latest comment (by time)
*
* @ Access public
* @ Param int $ page number
* @ Param int $ count the maximum number of records returned each time. a maximum of 200 records can be returned. the default value is 20.
* @ Return array
*/
Function comments_timeline ($ page = 1, $ count = 20)
 
 
/**
* Single comment list (by Weibo)
*
* @ Access public
* @ Param mixed $ the Weibo ID specified by sid
* @ Param int $ page number
* @ Param int $ count the maximum number of records returned each time. a maximum of 200 records can be returned. the default value is 20.
* @ Return array
*/
Function get_comments_by_sid ($ sid, $ page = 1, $ count = 20)
 
 
/**
* The number of comments and forwards on Weibo are counted in batches. a maximum of 100 comments can be obtained in one request.
*
* @ Access public
* @ Param mixed $ List of Weibo IDCs separated by commas (,)
* @ Return array
*/
Function get_count_info_by_ids ($ sids)
 
 
/**
* Reply to a Weibo comment.
*
* @ Access public
* @ Param mixed $ sid Weibo id
* @ Param mixed $ text comment content.
* @ Param mixed $ cid comment id
* @ Return array
*/
Function reply ($ sid, $ text, $ cid)
 
 
/**
* Returns the last 20 pieces of favorites posted by the user, which is consistent with the content returned on the user's favorites page.
*
* @ Access public
* @ Param bool $ page indicates the page number of the returned result.
* @ Return array
*/
Function get_favorites ($ page = false)
 
 
/**
* Add a microblog to favorites
*
* @ Access public
* @ Param mixed $ sid: Weibo id
* @ Return array
*/
Function add_to_favorites ($ sid)
 
 
/**
* Delete weibo favorites.
*
* @ Access public
* @ Param mixed $ ID of the microblog information to be deleted by sid.
* @ Return array
*/
Function remove_from_favorites ($ sid)


Function verify_credentials ()
 
/**
* Modify the Avatar
*
*/
Function update_avatar ($ pic_path)
 
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.