-
Notifications
You must be signed in to change notification settings - Fork 2
/
Documentation.txt
221 lines (104 loc) · 8.04 KB
/
Documentation.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
------------------------------------------------------------------------------------------------------------------------------
###### OAuth_Twitter.php Documentation ######
----------------------------------------------
Author : Basil B Thoppil
Version : 0.3 Alpha
Created on : 23 Jan 2010 01:20 am GMT+05:30
Last modified on: 21 Feb 2010 15:00 GMT+05:30
email : basilbthoppil@gmail.com
------------------------------------------------------------------------------------------------------------------------------
_________________ SETTING UP THE ENVIRONMENT ______________
****************************************************************
OAuth_Twitter works with Zend OAuth Library. So OAuth Library has to be there in your code base. For Zend Framework, you are
supposed to have complete OAuth library in /Library/OAuth.
Download OAuth_Twitter.php and include the library into your code. This library includes consumer.php from OAuth Package.
( Since library is coded and tested as a small Twitter project in Zend Framework, I would suggest this library as an ideal one for
Zend projects )
______________ REGISTERING YOUR APPLICATION WITH TWITTER ($config ) ______________
*************************************************************************************
You have to register your application with Twitter. We make use of the configuraiton details to get in touch with Twitter API
using this library.
The configuration details has to be assigned to an array and this array is the one and only argument to for the constructor of
'OAuth_Twitter' class
If access_token is already available, only that needs to be passed as configuration.
Optional save_token_in_session saves access token in current session $_SESSION['TWITTER_ACCESS_TOKEN']
$configuration = array(
'callbackUrl' => 'http://your_app.com/callback', //he callback url your app have registered with twitter
'siteUrl' => 'http://twitter.com/oauth', // The url with which your app contact Twitter API
'consumerKey' => '37yQOy5kvShfdWyRJp3SfdWy', // the consumer key provided from twitter
'consumerSecret' => '0VCb37y0V0VCb37yQOy5kvShfdWyRJp3SfdWyRJp3SXOxA' // the secret key provided from twitter
);
___________________ USING OAuth_Twitter methods in Your Code ____________________
************************************************************************************
Include the library to your code
require_once 'OAuth_twitter.php';
Creating an object of OAuth_Twitter
$my_twitter = new OAuth_Twitter($configuration)
---------------------------------------------------------------
*** To authenticate with Twitter account-- requestAuth() ***
---------------------------------------------------------------
This will set a session and redirect to the twitter authentication window. On successful authentication with Twitter
Twitter will redirect back to the callback URL.
---------------------------------------------------------------
*** Call back from Twitter --- handleCallback()
---------------------------------------------------------------
my_twitter->handleCallback()
handleCallback() will set the ACCESS_TOKEN to a SESSION variable access the Twitter API. Your application will use
this ACCESS_TOKEN for further access to the Twitter API
This internally calls saveAccessToken function, which now store the ACCESS_TOKEN in session (if save_in_session passed
in the configuration) or assigns to the private property.
To save access_token to Database, you may extend the class and override the saveAccessToken funciton
OR
use getAccessToken (returns the access_token being used - will not request for new, if its not found) function to get the access token OR get serialized access_token directly from session.
---------------------------------------------------------------
*** To Update the twitter status --- updateStatus($status)
---------------------------------------------------------------
@arg $status string | Latest update
It will check already authenticatied or not. If yes then update the status and return 1 if success.
If $string is NULL then function will return -1
If $string > 140 then will return -2
--------------------------------------------------------------------------
*** To get the followers using user_id --- getFollowersByUserId($user_id)
--------------------------------------------------------------------------
@arg $user_id | user_id of the user,
return all followers as an array of objects
--------------------------------------------------------------------------------------------
*** To get the followers using handle (screen name) --- getFollowersByHandle($screen_name)
--------------------------------------------------------------------------------------------
@arg $screen_name string | screen_name of the user,
eg. getFollowersByHandle('BasilBThoppil')
return all followers as an array of objects
***************************************************************************************************
**
-------- Jan 24 2010 21:55 GMT+530 ----------- by Basil B Thoppil <basilbthoppil@gmail.com>------
*****************************************************************************************************
--------------------------------------------------------------------------------------------
*** To get latest 20 updates of a specified user using (screen name) --- getPublicUpdatesByHandle($screen_name)
--------------------------------------------------------------------------------------------
@arg $screen_name string | screen_name of the user,
eg. getPublicUpdatesByHandle('BasilBThoppil')
return array includes 20 latest updates
--------------------------------------------------------------------------------------------
*** To get latest 20 updates of a specified user using handle using $user_id --- getPublicUpdatesByUserid($user_id)
--------------------------------------------------------------------------------------------
@arg $screen_name string | screen_name of the user,
eg. getPublicUpdatesByUserid(34566)
return array includes 20 latest updates (retarray[0]->'text')
--------------------------------------------------------------------------------------------
*** To get 20 most recent Updates of a LIST using user_id and list_id, --- getListUpdatesByUseridAndListId($user_id,$list_id)
--------------------------------------------------------------------------------------------
This is equivalent to the home page of a list :: like www.twitter.com/basilbthoppil/ente-collab
* @param string | int $user_id --- Twitter user_id of the user.
* @param string | int $list_id --- Twitter users list id of the user.
return array includes 20 latest updates (retarray[0]->'text')
--------------------------------------------------------------------------------------------
*** To * Get all list followers --- getListFollowersByListname($user_name,$list_name)
--------------------------------------------------------------------------------------------
* @param string | int $user_id --- Twitter user_id of the user.
* @param string | int $list_id --- Twitter users list id of the user.
return array includes 20 latest updates (retarray[0]->'text')
--------------------------------------------------------------------------------------------
*** To get most recent tweets contais the string provided, 'Search using a string' --- searchTweetsDetails($tweet)
--------------------------------------------------------------------------------------------
* @param string | int $tweet --- Search String.
return array includes 20 latest updates (retarray[0]->'text')