File: Zend_Service_Twitter.xml

package info (click to toggle)
zendframework 1.12.9%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 133,584 kB
  • sloc: xml: 1,311,829; php: 570,173; sh: 170; makefile: 125; sql: 121
file content (1108 lines) | stat: -rw-r--r-- 44,918 bytes parent folder | download | duplicates (2)
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.service.twitter" xmlns:xi="http://www.w3.org/2001/XInclude">
    <title>Zend_Service_Twitter</title>

    <sect2 id="zend.service.twitter.introduction">
        <title>Introduction</title>

        <para>
            <classname>Zend_Service_Twitter</classname> provides a client for the
            <ulink url="https://dev.twitter.com/docs/api/1.1">Twitter <acronym>API</acronym></ulink>.
            <classname>Zend_Service_Twitter</classname> allows you to query the public timeline. If
            you provide a username and OAuth details 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.
        </para>

        <para>
            <classname>Zend_Service_Twitter</classname> wraps all web service
            operations, including OAuth, and all methods return an instance of
            <classname>Zend_Service_Twitter_Response</classname>.
        </para>

        <para>
            <classname>Zend_Service_Twitter</classname> is broken up into subsections so you can
            easily identify which type of call is being requested.
        </para>

        <itemizedlist>
            <listitem>
                <para>
                    <code>account</code> allows you to check that your account credentials are
                    valid.
                </para>
            </listitem>

            <listitem>
                <para>
                    <code>application</code> allows you to check your <acronym>API</acronym> rate
                    limit.
                </para>
            </listitem>

            <listitem>
                <para>
                    <code>blocks</code> blocks and unblocks users from following you.
                </para>
            </listitem>

            <listitem>
                <para>
                    <code>directMessages</code> retrieves the authenticated user's received direct
                    messages, deletes direct messages, and sends new direct messages.
                </para>
            </listitem>

            <listitem>
                <para>
                    <code>favorites</code> lists, creates, and removes favorite tweets.
                </para>
            </listitem>

            <listitem>
                <para>
                    <code>friendships</code> creates and removes friendships for the
                    authenticated user.
                </para>
            </listitem>

            <listitem>
                <para>
                    <code>search</code> allows you to search statuses for specific criteria.
                </para>
            </listitem>

            <listitem>
                <para>
                    <code>statuses</code> retrieves the public and user timelines and
                    shows, updates, destroys, and retrieves replies for the authenticated user.
                </para>
            </listitem>

            <listitem>
                <para>
                    <code>users</code> retrieves friends and followers for the authenticated user
                    and returns extended information about a passed user.
                </para>
            </listitem>
        </itemizedlist>
    </sect2>

    <sect2 id="zend.service.twitter.authentication">
        <title>Authentication</title>

        <para>
            With the exception of fetching the public timeline,
            <classname>Zend_Service_Twitter</classname> requires authentication as a valid
            user. This is achieved using the OAuth authentication protocol. OAuth is
            the only supported authentication mode for Twitter as of August 2010. The OAuth
            implementation used by <classname>Zend_Service_Twitter</classname> is
            <classname>Zend_Oauth</classname>.
        </para>

        <example id="zend.service.twitter.authentication.example">
            <title>Creating the Twitter Class</title>

            <para>
                <classname>Zend_Service_Twitter</classname> must authorize itself, on behalf of a user, before use with the
                Twitter API (except for public timeline). This must be accomplished using OAuth since
                Twitter has disabled it's basic HTTP authentication as of August 2010.
            </para>

            <para>
                There are two options to establishing authorization. The first is to implement the
                workflow of <classname>Zend_Oauth</classname> via <classname>Zend_Service_Twitter</classname>
                which proxies to an internal <classname>Zend_Oauth_Consumer</classname> object. Please refer to
                the <classname>Zend_Oauth</classname> documentation for a full example of this
                workflow - you can call all documented <classname>Zend_Oauth_Consumer</classname> methods
                on <classname>Zend_Service_Twitter</classname> including constructor options. You may also
                use <classname>Zend_Oauth</classname> directly and only pass the resulting access
                token into <classname>Zend_Service_Twitter</classname>. This is the normal workflow
                once you have established a reusable access token for a particular Twitter user. The resulting OAuth
                access token should be stored to a database for future use (otherwise you will need to
                authorize for every new instance of <classname>Zend_Service_Twitter</classname>). Bear in mind
                that authorization via OAuth results in your user being redirected to Twitter to give their
                consent to the requested authorization (this is not repeated for stored access tokens). This will
                require additional work (i.e. redirecting users and hosting a callback URL) over the previous
                HTTP authentication mechanism where a user just
                needed to allow applications to store their username and password.
            </para>

            <para>The following example demonstrates setting up <classname>Zend_Service_Twitter</classname>
            which is given an already established OAuth access token. Please refer to the <classname>Zend_Oauth</classname>
            documentation to understand the workflow involved. The access token is a serializable object, so you may
            store the serialized object to a database, and unserialize it at retrieval time before passing the objects
            into <classname>Zend_Service_Twitter</classname>. The <classname>Zend_Oauth</classname> documentation
            demonstrates the workflow and objects involved.</para>

            <programlisting language="php"><![CDATA[
/**
 * We assume $serializedToken is the serialized token retrieved from a database
 * or even $_SESSION (if following the simple Zend_Oauth documented example)
 */
$token = unserialize($serializedToken);

$twitter = new Zend_Service_Twitter(array(
    'accessToken' => $token
    'oauth_options' => array(
        'username' => 'johndoe',
    ),
));

// verify user's credentials with Twitter
$response = $twitter->account->verifyCredentials();
]]></programlisting>
        </example>

        <note>
            <para>
                In order to authenticate with Twitter, ALL applications MUST be registered with
                Twitter in order to receive a Consumer Key and Consumer Secret to be used when
                authenticating with OAuth. This can not be reused across multiple applications -
                you must register each new application separately. Twitter access tokens have
                no expiry date, so storing them to a database is advised (they can, of course,
                be refreshed simply be repeating the OAuth authorization process). This can only
                be done while interacting with the user associated with that access token.
            </para>

            <para>
                The previous pre-OAuth version of <classname>Zend_Service_Twitter</classname>
                allowed passing in a username as the first parameter rather than within an array.
                This is no longer supported.
            </para>
        </note>

        <para>
            If you have registered an application with Twitter, you can also use the access token
            and access token secret they provide you in order to setup the OAuth consumer. This can
            be done as follows:
        </para>

        <programlisting language="php"><![CDATA[
$twitter = new Zend_Service_Twitter(array(
    'access_token' => array( // or use "accessToken" as the key; both work
        'token' => 'your-access-token',
        'secret' => 'your-access-token-secret',
    ),
    'oauth_options' => array( // or use "oauthOptions" as the key; both work
        'consumerKey' => 'your-consumer-key',
        'consumerSecret' => 'your-consumer-secret',
    ),
));
]]></programlisting>

        <para>
            If desired, you can also specify a specific HTTP client instance to use, or provide
            configuration for the HTTP client. To provide the HTTP client, use the
            <varname>http_client</varname> or <varname>httpClient</varname> key, and provide an
            instance. To provide HTTP client configuration for setting up an instance, use the key
            <varname>http_client_options</varname> or <varname>httpClientOptions</varname>. As a
            full example:
        </para>

        <programlisting language="php"><![CDATA[
$twitter = new Zend_Service_Twitter(array(
    'access_token' => array( // or use "accessToken" as the key; both work
        'token' => 'your-access-token',
        'secret' => 'your-access-token-secret',
    ),
    'oauth_options' => array( // or use "oauthOptions" as the key; both work
        'consumerKey' => 'your-consumer-key',
        'consumerSecret' => 'your-consumer-secret',
    ),
    'http_client_options' => array(
        'adapter' => 'Zend_Http_Client_Adapter_Curl',
    ),
));
]]></programlisting>
    </sect2>

    <sect2 id="zend.service.twitter.account">
        <title>Account Methods</title>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>verifyCredentials()</methodname> tests if supplied user
                    credentials are valid with minimal overhead.
                </para>

                <example id="zend.service.twitter.account.verifycredentails">
                    <title>Verifying credentials</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->account->verifyCredentials();
]]></programlisting>
                </example>
            </listitem>
        </itemizedlist>
    </sect2>

    <sect2 id="zend.service.twitter.application">
        <title>Application Methods</title>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>rateLimitStatus()</methodname> returns the remaining number of
                    <acronym>API</acronym> requests available to the authenticating user
                    before the <acronym>API</acronym> limit is reached for the current hour.
                </para>

                <example id="zend.service.twitter.application.ratelimitstatus">
                    <title>Rating limit status</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->application->rateLimitStatus();
$userTimelineLimit = $response->resources->statuses->{'/statuses/user_timeline'}->remaining;
]]></programlisting>
                </example>
            </listitem>
        </itemizedlist>
    </sect2>

    <sect2 id="zend.service.twitter.blocks">
        <title>Block Methods</title>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>create()</methodname> blocks the user specified in the
                    <code>id</code> parameter as the authenticating user and destroys a friendship
                    to the blocked user if one exists. Returns the blocked user when successful.
                </para>

                <example id="zend.service.twitter.blocks.create">
                    <title>Blocking a user</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->blocks->create('usertoblock');
]]></programlisting>
                </example>
            </listitem>

            <listitem>
                <para>
                    <methodname>destroy()</methodname> un-blocks the user specified in the
                    <code>id</code> parameter for the authenticating user. Returns the un-blocked
                    user in the requested format when successful.
                </para>

                <example id="zend.service.twitter.blocks.destroy">
                    <title>Removing a block</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->blocks->destroy('blockeduser');
]]></programlisting>
                </example>
            </listitem>

            <listitem>
                <para>
                    <methodname>ids()</methodname> returns an array of user identifiers that the
                    authenticating user is blocking.
                </para>

                <example id="zend.service.twitter.blocks.ids">
                    <title>Who are you blocking (identifiers only)</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->blocks->ids();
]]></programlisting>
                </example>
            </listitem>

            <listitem>
                <para>
                    <methodname>list()</methodname> returns an array of user objects that the
                    authenticating user is blocking.
                </para>

                <example id="zend.service.twitter.blocks.list">
                    <title>Who are you blocking</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->blocks->list();
]]></programlisting>
                </example>
            </listitem>
        </itemizedlist>
    </sect2>

    <sect2 id="zend.service.twitter.directmessages">
        <title>Direct Message Methods</title>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>messages()</methodname> returns a list of the 20 most recent direct
                    messages sent to the authenticating user.
                </para>

                <example id="zend.service.twitter.directmessages.messages">
                    <title>Retrieving recent direct messages received</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->directMessages->messages();
]]></programlisting>
                </example>

                <para>
                    The <methodname>messages()</methodname> method accepts an array of optional
                    parameters to modify the query.
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <code>since_id</code> narrows the returned results to just those
                            statuses after the specified identifier (up to 24 hours old).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>max_id</code> narrows the returned results to just those
                            statuses earlier than the specified identifier.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>count</code> specifies the number of statuses to return, up to 200.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>skip_status</code>, when set to boolean true, "t", or 1 will skip
                            including a user's most recent status in the results.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>include_entities</code> controls whether or not entities, which
                            includes URLs, mentioned users, and hashtags, will be returned.
                        </para>
                    </listitem>
                </itemizedlist>
            </listitem>

            <listitem>
                <para>
                    <methodname>sent()</methodname> returns a list of the 20 most recent direct
                    messages sent by the authenticating user.
                </para>

                <example id="zend.service.twitter.directmessages.sent">
                    <title>Retrieving recent direct messages sent</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->directMessages->sent();
]]></programlisting>
                </example>

                <para>
                    The <methodname>sent()</methodname> method accepts an array of optional
                    parameters to modify the query.
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <code>count</code> specifies the number of statuses to return, up to 20.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>page</code> specifies the page of results to return, based on the
                            <code>count</code> provided.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>since_id</code> narrows the returned results to just those
                            statuses after the specified identifier (up to 24 hours old).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>max_id</code> narrows the returned results to just those
                            statuses earlier than the specified identifier.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>include_entities</code> controls whether or not entities, which
                            includes URLs, mentioned users, and hashtags, will be returned.
                        </para>
                    </listitem>
                </itemizedlist>
            </listitem>

            <listitem>
                <para>
                    <methodname>new()</methodname> sends a new direct message to the specified user
                    from the authenticating user. Requires both the user and text parameters below.
                </para>

                <example id="zend.service.twitter.directmessages.new">
                    <title>Sending a direct message</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->directMessages->new('myfriend', 'mymessage');
]]></programlisting>
                </example>
            </listitem>

            <listitem>
                <para>
                    <methodname>destroy()</methodname> destroys the direct message specified in the
                    required <code>id</code> parameter. The authenticating user must be the
                    recipient of the specified direct message.
                </para>

                <example id="zend.service.twitter.directmessages.destroy">
                    <title>Deleting a direct message</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->directMessages->destroy(123548);
]]></programlisting>
                </example>
            </listitem>
        </itemizedlist>
    </sect2>

    <sect2 id="zend.service.twitter.favorites">
        <title>Favorites Methods</title>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>list()</methodname> returns the 20 most recent favorite
                    statuses for the authenticating user or user specified by the
                    <code>user_id</code> or <code>screen_name</code> parameter.
                </para>

                <example id="zend.service.twitter.favorites.list">
                    <title>Retrieving favorites</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->favorites->list();
]]></programlisting>
                </example>

                <para>
                    The <methodname>list()</methodname> method accepts an array of optional
                    parameters to modify the query.
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <code>user_id</code> specifies the ID of the user for whom to return the
                            timeline.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>screen_name</code> specifies the screen name of the user for
                            whom to return the timeline.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>since_id</code> narrows the returned results to just those
                            statuses after the specified identifier (up to 24 hours old).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>max_id</code> narrows the returned results to just those
                            statuses earlier than the specified identifier.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>count</code> specifies the number of statuses to return, up to 200.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>include_entities</code> controls whether or not entities, which
                            includes URLs, mentioned users, and hashtags, will be returned.
                        </para>
                    </listitem>
                </itemizedlist>
            </listitem>

            <listitem>
                <para>
                    <methodname>create()</methodname> favorites the status specified in the
                    <code>id</code> parameter as the authenticating user.
                </para>

                <example id="zend.service.twitter.favorites.create">
                    <title>Creating a favorite</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->favorites->create(12351);
]]></programlisting>
                </example>
            </listitem>

            <listitem>
                <para>
                    <methodname>destroy()</methodname> un-favorites the status specified in the
                    <code>id</code> parameter as the authenticating user.
                </para>

                <example id="zend.service.twitter.favorites.destroy">
                    <title>Deleting favorites</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->favorites->destroy(12351);
]]></programlisting>
                </example>
            </listitem>
        </itemizedlist>
    </sect2>

    <sect2 id="zend.service.twitter.friendships">
        <title>Friendship Methods</title>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>create()</methodname> befriends the user specified in the
                    <code>id</code> parameter with the authenticating user.
                </para>

                <example id="zend.service.twitter.friendships.create">
                    <title>Creating a friend</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->friendships->create('mynewfriend');
]]></programlisting>
                </example>
            </listitem>

            <listitem>
                <para>
                    <methodname>destroy()</methodname> discontinues friendship with the user
                    specified in the <code>id</code> parameter and the authenticating user.
                </para>

                <example id="zend.service.twitter.friendships.destroy">
                    <title>Deleting a friend</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->friendships->destroy('myoldfriend');
]]></programlisting>
                </example>
            </listitem>
        </itemizedlist>
    </sect2>

    <sect2 id="zend.service.twitter.search">
        <title>Search Methods</title>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>tweets()</methodname> returns a list of tweets matching the criteria
                    specified in <varname>$query</varname>. By default, 15 will be returned, but
                    this value may be changed using the <varname>count</varname> option.
                </para>

                <example id="zend.service.twitter.search.tweets">
                    <title>Searching for tweets</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->search->tweets('#zendframework');
]]></programlisting>
                </example>

                <para>
                    The <methodname>tweets()</methodname> method accepts an optional second
                    argument, an array of optional parameters to modify the query.
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <code>since_id</code> narrows the returned results to just those
                            statuses after the specified identifier (up to 24 hours old).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>max_id</code> narrows the returned results to just those
                            statuses earlier than the specified identifier.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>count</code> specifies the number of statuses to return, up to 200.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>include_entities</code> controls whether or not entities, which
                            includes URLs, mentioned users, and hashtags, will be returned.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>lang</code> indicates which two-letter language code to restrict
                            results to.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>locale</code> indicates which two-letter language code is being
                            used in the query.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>geocode</code> can be used to indicate the geographical radius in
                            which tweets should originate; the string should be in the form
                            "latitude,longitude,radius", with "radius" being a unit followed by one
                            of "mi" or "km".
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>result_type</code> indicates what type of results to retrieve, and
                            should be one of "mixed," "recent," or "popular."
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>until</code> can be used to specify a the latest date for which to
                            return tweets.
                        </para>
                    </listitem>
                </itemizedlist>
            </listitem>
        </itemizedlist>
    </sect2>

    <sect2 id="zend.service.twitter.statuses">
        <title>Status Methods</title>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>sample()</methodname> returns the 20 most recent statuses
                    from non-protected users with a custom user icon. The public timeline is cached
                    by Twitter for 60 seconds.
                </para>

                <example id="zend.service.twitter.statuses.sample">
                    <title>Retrieving public timeline</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->statuses->sample();
]]></programlisting>
                </example>
            </listitem>

            <listitem>
                <para>
                    <methodname>homeTimeline()</methodname> returns the 20 most recent statuses
                    posted by the authenticating user and that user's friends.
                </para>

                <example id="zend.service.twitter.statuses.hometimeline">
                    <title>Retrieving the home timeline</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
));
$response = $twitter->statuses->homeTimeline();
]]></programlisting>
                </example>

                <para>
                    The <methodname>homeTimeline()</methodname> method accepts an array of
                    optional parameters to modify the query.
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <code>since_id</code> narrows the returned results to just those
                            statuses after the specified identifier (up to 24 hours old).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>max_id</code> narrows the returned results to just those
                            statuses earlier than the specified identifier.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>count</code> specifies the number of statuses to return, up to 200.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>trim_user</code>, when set to boolean true, "t", or 1, will list
                            the author identifier only in embedded user objects in the statuses
                            returned.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>contributor_details</code>, when set to boolean true, will return
                            the screen name of any contributors to a status (instead of only the
                            contributor identifier).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>include_entities</code> controls whether or not entities, which
                            includes URLs, mentioned users, and hashtags, will be returned.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>exclude_replies</code> controls whether or not status updates that
                            are in reply to other statuses will be returned.
                        </para>
                    </listitem>
                </itemizedlist>
            </listitem>

            <listitem>
                <para>
                    <methodname>userTimeline()</methodname> returns the 20 most recent statuses
                    posted from the authenticating user.
                </para>

                <example id="zend.service.twitter.statuses.usertimeline">
                    <title>Retrieving user timeline</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->statuses->userTimeline();
]]></programlisting>
                </example>

                <para>
                    The <methodname>userTimeline()</methodname> method accepts an array of optional
                    parameters to modify the query.
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <code>user_id</code> specifies the ID of the user for whom to return the
                            timeline.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>screen_name</code> specifies the screen name of the user for
                            whom to return the timeline.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>since_id</code> narrows the returned results to just those
                            statuses after the specified identifier (up to 24 hours old).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>max_id</code> narrows the returned results to just those
                            statuses earlier than the specified identifier.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>count</code> specifies the number of statuses to return, up to 200.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>trim_user</code>, when set to boolean true, "t", or 1, will list
                            the author identifier only in embedded user objects in the statuses
                            returned.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>contributor_details</code>, when set to boolean true, will return
                            the screen name of any contributors to a status (instead of only the
                            contributor identifier).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>include_rts</code> controls whether or not to include native
                            retweets in the returned list.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>exclude_replies</code> controls whether or not status updates that
                            are in reply to other statuses will be returned.
                        </para>
                    </listitem>
                </itemizedlist>
            </listitem>

            <listitem>
                <para>
                    <methodname>show()</methodname> returns a single status, specified by the
                    <code>id</code> parameter below. The status' author will be returned inline.
                </para>

                <example id="zend.service.twitter.statuses.show">
                    <title>Showing user status</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->statuses->show(1234);
]]></programlisting>
                </example>
            </listitem>

            <listitem>
                <para>
                    <methodname>update()</methodname> updates the authenticating user's status.
                    This method requires that you pass in the status update that you want to post
                    to Twitter.
                </para>

                <example id="zend.service.twitter.statuses.update">
                    <title>Updating user status</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->statuses->update('My Great Tweet');
]]></programlisting>
                </example>

                <para>
                    The <methodname>update()</methodname> method accepts a second additional
                    parameter.
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <code>inReplyToStatusId</code> specifies the ID of an existing
                            status that the status to be posted is in reply to.
                        </para>
                    </listitem>
                </itemizedlist>
            </listitem>

            <listitem>
                <para>
                    <methodname>mentionsTimeline()</methodname> returns the 20 most recent @replies
                    (status updates prefixed with @username) for the authenticating user.
                </para>

                <example id="zend.service.twitter.statuses.mentionstimeline">
                    <title>Showing user replies</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->statuses->mentionsTimeline();
]]></programlisting>
                </example>

                <para>
                    The <methodname>mentionsTimeline()</methodname> method accepts an array of
                    optional parameters to modify the query.
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <code>since_id</code> narrows the returned results to just those
                            statuses after the specified identifier (up to 24 hours old).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>max_id</code> narrows the returned results to just those
                            statuses earlier than the specified identifier.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>count</code> specifies the number of statuses to return, up to 200.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>trim_user</code>, when set to boolean true, "t", or 1, will list
                            the author identifier only in embedded user objects in the statuses
                            returned.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>contributor_details</code>, when set to boolean true, will return
                            the screen name of any contributors to a status (instead of only the
                            contributor identifier).
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>include_entities</code> controls whether or not entities, which
                            includes URLs, mentioned users, and hashtags, will be returned.
                        </para>
                    </listitem>
                </itemizedlist>
            </listitem>

            <listitem>
                <para>
                    <methodname>destroy()</methodname> destroys the status specified by the
                    required <code>id</code> parameter.
                </para>

                <example id="zend.service.twitter.statuses.destroy">
                    <title>Deleting user status</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->statuses->destroy(12345);
]]></programlisting>
                </example>
            </listitem>
        </itemizedlist>
    </sect2>

    <sect2 id="zend.service.twitter.users">
        <title>User Methods</title>

        <itemizedlist>
            <listitem>
                <para>
                    <methodname>show()</methodname> returns extended information of a given user,
                    specified by ID or screen name as per the required <code>id</code>
                    parameter below.
                </para>

                <example id="zend.service.twitter.users.show">
                    <title>Showing user informations</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->users->show('myfriend');
]]></programlisting>
                </example>
            </listitem>

            <listitem>
                <para>
                    <methodname>search()</methodname> will search for users matching the query
                    provided.
                </para>

                <example id="zend.service.twitter.users.search">
                    <title>Searching for users</title>

                    <programlisting language="php"><![CDATA[
$twitter  = new Zend_Service_Twitter($options);
$response = $twitter->users->search('Zend');
]]></programlisting>
                </example>

                <para>
                    The <methodname>search()</methodname> method accepts an array of
                    optional parameters to modify the query.
                </para>

                <itemizedlist>
                    <listitem>
                        <para>
                            <code>count</code> specifies the number of statuses to return, up to 20.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>page</code> specifies the page of results to return, based on the
                            <code>count</code> provided.
                        </para>
                    </listitem>

                    <listitem>
                        <para>
                            <code>include_entities</code> controls whether or not entities, which
                            includes URLs, mentioned users, and hashtags, will be returned.
                        </para>
                    </listitem>
                </itemizedlist>
            </listitem>
        </itemizedlist>
    </sect2>
</sect1>
<!--
vim:se ts=4 sw=4 et:
-->