Zend_Service_TwitterIntroductionZend_Service_Twitter provides a client for the » Twitter REST API. Zend_Service_Twitter allows you to query the public timeline. If you provide a username and password for Twitter, it will allow you to get and update your status, reply to friends, direct message friends, mark tweets as favorite, and much more. Zend_Service_Twitter is implementing a REST service, and all methods return an instance of Zend_Rest_Client_Result. Zend_Service_Twitter is broken up into subsections so you can easily identify which type of call is being requested.
AuthenticationWith the exception of fetching the public timeline, Zend_Service_Twitter requires authentication to work. Twitter currently uses » HTTP Basic Authentication. You can pass in your username or registered email along with your password for Twitter to login. Example #1 Creating the Twitter Class The following code sample is how you create the Twitter service, pass in your username and password, and verify that they are correct.
You can also pass in an array that contains the username and password as the first argument.
Account Methods
Status Methods
User Methods
Direct Message Methods
Friendship Methods
Favorite Methods
Block Methods
Zend_Service_Twitter_SearchIntroductionZend_Service_Twitter_Search provides a client for the » Twitter Search API. The Twitter Search service is use to search Twitter. Currently, it only returns data in Atom or JSON format, but a full REST service is in the future, which will support XML responses. Twitter TrendsReturns the top ten queries that are currently trending on Twitter. The response includes the time of the request, the name of each trending topic, and the url to the Twitter Search results page for that topic. Currently the search API for trends only supports a JSON return so the function returns an array.
The return array has two values in it:
Searching TwitterUsing the search method returns tweets that match a specific query. There are a number of » Search Operators that you can use to query with. The search method can accept six different optional URL parameters passed in as an array:
Example #29 JSON Search Example The following code sample will return an array with the search results.
Example #30 ATOM Search Example The following code sample will return a Zend_Feed_Atom object.
Zend-specific Accessor MethodsWhile the Twitter Search API only specifies two methods, Zend_Service_Twitter_Search has additional methods that may be used for retrieving and modifying internal properties.
|
|