/
api.rb
2798 lines (2658 loc) · 162 KB
/
api.rb
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
require 'twitter/action_factory'
require 'twitter/configuration'
require 'twitter/core_ext/array'
require 'twitter/core_ext/enumerable'
require 'twitter/core_ext/hash'
require 'twitter/core_ext/kernel'
require 'twitter/cursor'
require 'twitter/direct_message'
require 'twitter/error/forbidden'
require 'twitter/error/not_found'
require 'twitter/language'
require 'twitter/list'
require 'twitter/oembed'
require 'twitter/place'
require 'twitter/rate_limit_status'
require 'twitter/relationship'
require 'twitter/saved_search'
require 'twitter/search_results'
require 'twitter/settings'
require 'twitter/suggestion'
require 'twitter/trend'
require 'twitter/tweet'
require 'twitter/user'
module Twitter
module API
DEFAULT_CURSOR = -1
MAX_USERS_PER_REQUEST = 100
METHOD_RATE_LIMITED = {
:accept => false,
:activity_about_me => true,
:activity_by_friends => true,
:block => true,
:block? => true,
:blocked_ids => true,
:blocking => true,
:configuration => true,
:contributees => true,
:contributors => true,
:current_user => true,
:d => false,
:deny => false,
:direct_message => true,
:direct_message_create => false,
:direct_message_destroy => false,
:direct_messages => true,
:direct_messages_received => true,
:direct_messages_sent => true,
:disable_notifications => false,
:enable_notifications => false,
:end_session => false,
:fav => false,
:fave => false,
:favorite => false,
:favorite_create => false,
:favorite_destroy => false,
:favorites => true,
:follow => false,
:follow! => false,
:follower_ids => true,
:following_followers_of => true,
:friend_ids => true,
:friendship => true,
:friendship? => true,
:friendship_create => false,
:friendship_create! => false,
:friendship_destroy => false,
:friendship_show => true,
:friendship_update => false,
:friendships => true,
:friendships_incoming => true,
:friendships_outgoing => true,
:geo_search => true,
:home_timeline => true,
:initialize => false,
:languages => true,
:list => true,
:list_add_member => false,
:list_add_members => false,
:list_create => false,
:list_destroy => false,
:list_member? => true,
:list_members => true,
:list_remove_member => false,
:list_remove_members => false,
:list_subscribe => false,
:list_subscriber? => true,
:list_subscribers => true,
:list_timeline => true,
:list_unsubscribe => false,
:list_update => false,
:lists => true,
:lists_subscribed_to => true,
:local_trends => true,
:m => false,
:media_timeline => true,
:memberships => true,
:mentions => true,
:network_timeline => true,
:no_retweet_ids => true,
:oembed => true,
:oembeds => true,
:phoenix_search => true,
:place => true,
:place_create => true,
:places_nearby => true,
:places_similar => true,
:privacy => true,
:rate_limit_status => false,
:rate_limited? => false,
:related_results => true,
:related_statuses => true,
:related_tweets => true,
:recommendations => true,
:relationship => true,
:report_spam => true,
:retweet => true,
:retweeted_by => false,
:retweeted_by_me => true,
:retweeted_by_user => false,
:retweeted_to => true,
:retweeted_to_me => true,
:retweeted_to_user => true,
:retweeters_of => true,
:retweets => true,
:retweets_of_me => true,
:reverse_geocode => true,
:saved_search => true,
:saved_search_create => false,
:saved_search_destroy => false,
:saved_searches => true,
:search => true,
:settings => true,
:status => true,
:status_activity => true,
:status_destroy => false,
:statuses => true,
:statuses_activity => true,
:subscriptions => true,
:suggest_users => true,
:suggestions => true,
:tos => true,
:trend_locations => true,
:trends => true,
:trends_daily => true,
:trends_weekly => true,
:tweet_activity => true,
:tweet_destroy => false,
:unblock => false,
:unfavorite => false,
:unfollow => false,
:update => false,
:update_delivery_device => false,
:update_profile => false,
:update_profile_background_image => false,
:update_profile_colors => false,
:update_profile_image => false,
:update_with_media => false,
:user => true,
:user? => true,
:user_search => true,
:user_timeline => true,
:users => true,
:verify_credentials => true,
}
# Check whether a method is rate limited
#
# @raise [ArgumentError] Error raised when supplied argument is not a key in the METHOD_RATE_LIMITED hash.
# @return [Boolean]
# @param method_name [Symbol]
def rate_limited?(method_name)
method_rate_limited = METHOD_RATE_LIMITED[method_name.to_sym]
raise ArgumentError.new("no method `#{method_name}' for #{self.class}") if method_rate_limited.nil?
method_rate_limited
end
# Returns the remaining number of API requests available to the requesting user
#
# @see https://dev.twitter.com/docs/api/1/get/account/rate_limit_status
# @rate_limited No
# @authentication_required No
# @return [Twitter::RateLimitStatus]
# @param options [Hash] A customizable set of options.
# @example Return the remaining number of API requests available to the requesting user
# Twitter.rate_limit_status
def rate_limit_status(options={})
object_from_response(Twitter::RateLimitStatus, :get, "/1/account/rate_limit_status.json", options)
end
# Returns the requesting user if authentication was successful, otherwise raises {Twitter::Error::Unauthorized}
#
# @see https://dev.twitter.com/docs/api/1/get/account/verify_credentials
# @rate_limited Yes
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::User] The authenticated user.
# @param options [Hash] A customizable set of options.
# @option options [Boolean, String, Integer] :skip_status Do not include user's Tweets when set to true, 't' or 1.
# @example Return the requesting user if authentication was successful
# Twitter.verify_credentials
def verify_credentials(options={})
object_from_response(Twitter::User, :get, "/1/account/verify_credentials.json", options)
end
alias current_user verify_credentials
# Ends the session of the authenticating user
#
# @see https://dev.twitter.com/docs/api/1/post/account/end_session
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Hash]
# @param options [Hash] A customizable set of options.
# @example End the session of the authenticating user
# Twitter.end_session
def end_session(options={})
post("/1/account/end_session.json", options)[:body]
end
# Sets which device Twitter delivers updates to for the authenticating user
#
# @see https://dev.twitter.com/docs/api/1/post/account/update_delivery_device
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::User] The authenticated user.
# @param device [String] Must be one of: 'sms', 'none'.
# @param options [Hash] A customizable set of options.
# @example Turn SMS updates on for the authenticating user
# Twitter.update_delivery_device('sms')
def update_delivery_device(device, options={})
object_from_response(Twitter::User, :post, "/1/account/update_delivery_device.json", options.merge(:device => device))
end
# Sets values that users are able to set under the "Account" tab of their settings page
#
# @see https://dev.twitter.com/docs/api/1/post/account/update_profile
# @note Only the options specified will be updated.
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::User] The authenticated user.
# @param options [Hash] A customizable set of options.
# @option options [String] :name Full name associated with the profile. Maximum of 20 characters.
# @option options [String] :url URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.
# @option options [String] :location The city or country describing where the user of the account is located. The contents are not normalized or geocoded in any way. Maximum of 30 characters.
# @option options [String] :description A description of the user owning the account. Maximum of 160 characters.
# @example Set authenticating user's name to Erik Michaels-Ober
# Twitter.update_profile(:name => "Erik Michaels-Ober")
def update_profile(options={})
object_from_response(Twitter::User, :post, "/1/account/update_profile.json", options)
end
# Updates the authenticating user's profile background image
#
# @see https://dev.twitter.com/docs/api/1/post/account/update_profile_background_image
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::User] The authenticated user.
# @param image [File] The background image for the profile, base64-encoded. Must be a valid GIF, JPG, or PNG image of less than 800 kilobytes in size. Images with width larger than 2048 pixels will be forcibly scaled down. The image must be provided as raw multipart data, not a URL.
# @param options [Hash] A customizable set of options.
# @option options [Boolean] :tile Whether or not to tile the background image. If set to true the background image will be displayed tiled. The image will not be tiled otherwise.
# @example Update the authenticating user's profile background image
# Twitter.update_profile_background_image(File.new("we_concept_bg2.png"))
def update_profile_background_image(image, options={})
object_from_response(Twitter::User, :post, "/1/account/update_profile_background_image.json", options.merge(:image => image))
end
# Sets one or more hex values that control the color scheme of the authenticating user's profile
#
# @see https://dev.twitter.com/docs/api/1/post/account/update_profile_colors
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::User] The authenticated user.
# @param options [Hash] A customizable set of options.
# @option options [String] :profile_background_color Profile background color.
# @option options [String] :profile_text_color Profile text color.
# @option options [String] :profile_link_color Profile link color.
# @option options [String] :profile_sidebar_fill_color Profile sidebar's background color.
# @option options [String] :profile_sidebar_border_color Profile sidebar's border color.
# @example Set authenticating user's profile background to black
# Twitter.update_profile_colors(:profile_background_color => '000000')
def update_profile_colors(options={})
object_from_response(Twitter::User, :post, "/1/account/update_profile_colors.json", options)
end
# Updates the authenticating user's profile image
#
# @see https://dev.twitter.com/docs/api/1/post/account/update_profile_image
# @note This method asynchronously processes the uploaded file before updating the user's profile image URL. You can either update your local cache the next time you request the user's information, or, at least 5 seconds after uploading the image, ask for the updated URL using {Twitter::User#profile_image_url}.
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::User] The authenticated user.
# @param image [File] The avatar image for the profile, base64-encoded. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 500 pixels will be scaled down. Animated GIFs will be converted to a static GIF of the first frame, removing the animation.
# @param options [Hash] A customizable set of options.
# @example Update the authenticating user's profile image
# Twitter.update_profile_image(File.new("me.jpeg"))
def update_profile_image(image, options={})
object_from_response(Twitter::User, :post, "/1/account/update_profile_image.json", options.merge(:image => image))
end
# Updates the authenticating user's profile banner image
#
# @see https://dev.twitter.com/docs/api/1/post/account/update_profile_banner
# @note Uploads a profile banner on behalf of the authenticating user. For best results, upload an <5MB image that is exactly 1252px by 626px. Images will be resized for a number of display options. Users with an uploaded profile banner will have a profile_banner_url node in their Users objects. More information about sizing variations can be found in User Profile Images and Banners.
# @note Profile banner images are processed asynchronously. The profile_banner_url and its variant sizes will not necessary be available directly after upload.
# @rate_limited No
# @authentication_required Requires user context
# @raise [Twitter::Error::BadRequest] Error raised when either an image was not provided or the image data could not be processed.
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @raise [Twitter::Error::UnprocessableEntity] Error raised when the image could not be resized or is too large.
# @return [nil]
# @param image [File] The Base64-encoded or raw image data being uploaded as the user's new profile banner.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :width The width of the preferred section of the image being uploaded in pixels. Use with height, offset_left, and offset_top to select the desired region of the image to use.
# @option options [Integer] :height The height of the preferred section of the image being uploaded in pixels. Use with width, offset_left, and offset_top to select the desired region of the image to use.
# @option options [Integer] :offset_left The number of pixels by which to offset the uploaded image from the left. Use with height, width, and offset_top to select the desired region of the image to use.
# @option options [Integer] :offset_top The number of pixels by which to offset the uploaded image from the top. Use with height, width, and offset_left to select the desired region of the image to use.
# @example Update the authenticating user's profile banner
# Twitter.update_profile_banner(File.new("me.jpeg"))
def update_profile_banner(banner, options={})
post("/1/account/update_profile_banner.json", options.merge(:banner => banner))[:body]
end
# Removes the authenticating user's profile banner image
#
# @see https://dev.twitter.com/docs/api/1/post/account/remove_profile_banner
# @rate_limited No
# @authentication_required Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [nil]
# @param options [Hash] A customizable set of options.
# @example Remove the authenticating user's profile banner image
# Twitter.remove_profile_banner
def remove_profile_banner(options={})
post("/1/account/remove_profile_banner.json", options)[:body]
end
# Updates the authenticating user's settings.
# Or, if no options supplied, returns settings (including current trend, geo and sleep time information) for the authenticating user.
#
# @see https://dev.twitter.com/docs/api/1/post/account/settings
# @see https://dev.twitter.com/docs/api/1/get/account/settings
# @rate_limited Yes
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::Settings]
# @param options [Hash] A customizable set of options.
# @option options [Integer] :trend_location_woeid The Yahoo! Where On Earth ID to use as the user's default trend location. Global information is available by using 1 as the WOEID. The woeid must be one of the locations returned by {https://dev.twitter.com/docs/api/1/get/trends/available GET trends/available}.
# @option options [Boolean, String, Integer] :sleep_time_enabled When set to true, 't' or 1, will enable sleep time for the user. Sleep time is the time when push or SMS notifications should not be sent to the user.
# @option options [Integer] :start_sleep_time The hour that sleep time should begin if it is enabled. The value for this parameter should be provided in {http://en.wikipedia.org/wiki/ISO_8601 ISO8601} format (i.e. 00-23). The time is considered to be in the same timezone as the user's time_zone setting.
# @option options [Integer] :end_sleep_time The hour that sleep time should end if it is enabled. The value for this parameter should be provided in {http://en.wikipedia.org/wiki/ISO_8601 ISO8601} format (i.e. 00-23). The time is considered to be in the same timezone as the user's time_zone setting.
# @option options [String] :time_zone The timezone dates and times should be displayed in for the user. The timezone must be one of the {http://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html Rails TimeZone} names.
# @option options [String] :lang The language which Twitter should render in for this user. The language must be specified by the appropriate two letter ISO 639-1 representation. Currently supported languages are provided by {https://dev.twitter.com/docs/api/1/get/help/languages GET help/languages}.
# @example Return the settings for the authenticating user.
# Twitter.settings
def settings(options={})
request_method = options.size.zero? ? :get : :post
object_from_response(Twitter::Settings, request_method, "1/account/settings.json", options)
end
# Returns activity about me
#
# @note Undocumented
# @rate_limited Yes
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array] An array of actions
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @example Return activity about me
# Twitter.activity_about_me
def activity_about_me(options={})
collection_from_response(Twitter::ActionFactory, :get, "/i/activity/about_me.json", options)
end
# Returns activity by friends
#
# @note Undocumented
# @rate_limited Yes
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid./
# @return [Array] An array of actions
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @example Return activity by friends
# Twitter.activity_by_friends
def activity_by_friends(options={})
collection_from_response(Twitter::ActionFactory, :get, "/i/activity/by_friends.json", options)
end
# Returns the 20 most recent direct messages sent to the authenticating user
#
# @see https://dev.twitter.com/docs/api/1/get/direct_messages
# @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
# @rate_limited Yes
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::DirectMessage>] Direct messages sent to the authenticating user.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
# @option options [Integer] :page Specifies the page of results to retrieve.
# @example Return the 20 most recent direct messages sent to the authenticating user
# Twitter.direct_messages_received
def direct_messages_received(options={})
collection_from_response(Twitter::DirectMessage, :get, "/1/direct_messages.json", options)
end
# Returns the 20 most recent direct messages sent by the authenticating user
#
# @see https://dev.twitter.com/docs/api/1/get/direct_messages/sent
# @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
# @rate_limited Yes
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::DirectMessage>] Direct messages sent by the authenticating user.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
# @option options [Integer] :page Specifies the page of results to retrieve.
# @example Return the 20 most recent direct messages sent by the authenticating user
# Twitter.direct_messages_sent
def direct_messages_sent(options={})
collection_from_response(Twitter::DirectMessage, :get, "/1/direct_messages/sent.json", options)
end
# Destroys direct messages
#
# @see https://dev.twitter.com/docs/api/1/post/direct_messages/destroy/:id
# @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::DirectMessage>] Deleted direct message.
# @overload direct_message_destroy(*ids)
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
# @example Destroys the direct message with the ID 1825785544
# Twitter.direct_message_destroy(1825785544)
# @overload direct_message_destroy(*ids, options)
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
# @param options [Hash] A customizable set of options.
def direct_message_destroy(*args)
destroy(Twitter::DirectMessage, :delete, "/1/direct_messages/destroy", args)
end
# Sends a new direct message to the specified user from the authenticating user
#
# @see https://dev.twitter.com/docs/api/1/post/direct_messages/new
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::DirectMessage] The sent message.
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
# @param text [String] The text of your direct message, up to 140 characters.
# @param options [Hash] A customizable set of options.
# @example Send a direct message to @sferik from the authenticating user
# Twitter.direct_message_create('sferik', "I'm sending you this message via @gem!")
# Twitter.direct_message_create(7505382, "I'm sending you this message via @gem!") # Same as above
def direct_message_create(user, text, options={})
options.merge_user!(user)
object_from_response(Twitter::DirectMessage, :post, "/1/direct_messages/new.json", options.merge(:text => text))
end
alias d direct_message_create
alias m direct_message_create
# Returns a direct message
#
# @see https://dev.twitter.com/docs/api/1/get/direct_messages/show/%3Aid
# @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
# @rate_limited Yes
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::DirectMessage] The requested messages.
# @param id [Integer] A Tweet IDs.
# @param options [Hash] A customizable set of options.
# @example Return the direct message with the id 1825786345
# Twitter.direct_message(1825786345)
def direct_message(id, options={})
object_from_response(Twitter::DirectMessage, :get, "/1/direct_messages/show/#{id}.json", options)
end
# @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information.
# @rate_limited Yes
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::DirectMessage>] The requested messages.
# @overload direct_messages(options={})
# Returns the 20 most recent direct messages sent to the authenticating user
#
# @see https://dev.twitter.com/docs/api/1/get/direct_messages
# @param options [Hash] A customizable set of options.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200.
# @option options [Integer] :page Specifies the page of results to retrieve.
# @example Return the 20 most recent direct messages sent to the authenticating user
# Twitter.direct_messages
# @overload direct_messages(*ids)
# Returns direct messages
#
# @see https://dev.twitter.com/docs/api/1/get/direct_messages/show/%3Aid
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
# @example Return the direct message with the id 1825786345
# Twitter.direct_messages(1825786345)
# @overload direct_messages(*ids, options)
# Returns direct messages
#
# @see https://dev.twitter.com/docs/api/1/get/direct_messages/show/%3Aid
# @param ids [Array<Integer>, Set<Integer>] An array of Tweet IDs.
# @param options [Hash] A customizable set of options.
def direct_messages(*args)
options = args.extract_options!
if args.empty?
direct_messages_received(options)
else
args.flatten.threaded_map do |id|
object_from_response(Twitter::DirectMessage, :get, "/1/direct_messages/show/#{id}.json", options)
end
end
end
# @see https://dev.twitter.com/docs/api/1/get/followers/ids
# @rate_limited Yes
# @authentication_required No unless requesting it from a protected user
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::Cursor]
# @overload follower_ids(options={})
# Returns an array of numeric IDs for every user following the authenticated user
#
# @param options [Hash] A customizable set of options.
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
# @example Return the authenticated user's followers' IDs
# Twitter.follower_ids
# @overload follower_ids(user, options={})
# Returns an array of numeric IDs for every user following the specified user
#
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :cursor (-1) Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1 to begin paging. Provide values as returned in the response body's next_cursor and previous_cursor attributes to page back and forth in the list.
# @example Return @sferik's followers' IDs
# Twitter.follower_ids('sferik')
# Twitter.follower_ids(7505382) # Same as above
def follower_ids(*args)
ids_from_response(:get, "/1/followers/ids.json", args)
end
# @see https://dev.twitter.com/docs/api/1/get/friends/ids
# @rate_limited Yes
# @authentication_required No unless requesting it from a protected user
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::Cursor]
# @overload friend_ids(options={})
# Returns an array of numeric IDs for every user the authenticated user is following
#
# @param options [Hash] A customizable set of options.
# @option options [Integer] :cursor (-1) Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1 to begin paging. Provide values as returned in the response body's next_cursor and previous_cursor attributes to page back and forth in the list.
# @example Return the authenticated user's friends' IDs
# Twitter.friend_ids
# @overload friend_ids(user, options={})
# Returns an array of numeric IDs for every user the specified user is following
#
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
# @example Return @sferik's friends' IDs
# Twitter.friend_ids('sferik')
# Twitter.friend_ids(7505382) # Same as above
def friend_ids(*args)
ids_from_response(:get, "/1/friends/ids.json", args)
end
# Test for the existence of friendship between two users
#
# @see https://dev.twitter.com/docs/api/1/get/friendships/exists
# @note Consider using {Twitter::API::Friendships#friendship} instead of this method.
# @rate_limited Yes
# @authentication_required No unless user_a or user_b is protected
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Boolean] true if user_a follows user_b, otherwise false.
# @param user_a [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the subject user.
# @param user_b [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the user to test for following.
# @param options [Hash] A customizable set of options.
# @example Return true if @sferik follows @pengwynn
# Twitter.friendship?('sferik', 'pengwynn')
# Twitter.friendship?('sferik', 14100886) # Same as above
# Twitter.friendship?(7505382, 14100886) # Same as above
def friendship?(user_a, user_b, options={})
options.merge_user!(user_a, nil, "a")
options.merge_user!(user_b, nil, "b")
get("/1/friendships/exists.json", options)[:body]
end
# Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user
#
# @see https://dev.twitter.com/docs/api/1/get/friendships/incoming
# @rate_limited Yes
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::Cursor]
# @param options [Hash] A customizable set of options.
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
# @example Return an array of numeric IDs for every user who has a pending request to follow the authenticating user
# Twitter.friendships_incoming
def friendships_incoming(options={})
cursor_from_response(:ids, nil, :get, "/1/friendships/incoming.json", {:cursor => DEFAULT_CURSOR}.merge(options))
end
# Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
#
# @see https://dev.twitter.com/docs/api/1/get/friendships/outgoing
# @rate_limited Yes
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::Cursor]
# @param options [Hash] A customizable set of options.
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
# @example Return an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
# Twitter.friendships_outgoing
def friendships_outgoing(options={})
cursor_from_response(:ids, nil, :get, "/1/friendships/outgoing.json", {:cursor => DEFAULT_CURSOR}.merge(options))
end
# Returns detailed information about the relationship between two users
#
# @see https://dev.twitter.com/docs/api/1/get/friendships/show
# @rate_limited Yes
# @authentication_required No
# @return [Twitter::Relationship]
# @param source [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the source user.
# @param target [Integer, String, Twitter::User] The Twitter user ID, screen name, or object of the target user.
# @param options [Hash] A customizable set of options.
# @example Return the relationship between @sferik and @pengwynn
# Twitter.friendship('sferik', 'pengwynn')
# Twitter.friendship('sferik', 14100886) # Same as above
# Twitter.friendship(7505382, 14100886) # Same as above
def friendship(source, target, options={})
options.merge_user!(source, "source")
options[:source_id] = options.delete(:source_user_id) unless options[:source_user_id].nil?
options.merge_user!(target, "target")
options[:target_id] = options.delete(:target_user_id) unless options[:target_user_id].nil?
object_from_response(Twitter::Relationship, :get, "/1/friendships/show.json", options)
end
alias friendship_show friendship
alias relationship friendship
# Allows the authenticating user to follow the specified users, unless they are already followed
#
# @see https://dev.twitter.com/docs/api/1/post/friendships/create
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::User>] The followed users.
# @overload(*users)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @example Follow @sferik
# Twitter.follow('sferik')
# @overload(*users, options)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @param options [Hash] A customizable set of options.
# @option options [Boolean] :follow (false) Enable notifications for the target user.
def follow(*args)
options = args.extract_options!
# Twitter always turns on notifications if the "follow" option is present, even if it's set to false
# so only send follow if it's true
options.merge!(:follow => true) if options.delete(:follow)
existing_friends = Thread.new do
friend_ids.ids
end
new_friends = Thread.new do
users(args).map(&:id)
end
follow!(new_friends.value - existing_friends.value, options)
end
alias friendship_create follow
# Allows the authenticating user to follow the specified users
#
# @see https://dev.twitter.com/docs/api/1/post/friendships/create
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::User>] The followed users.
# @overload follow!(*users)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @example Follow @sferik
# Twitter.follow!('sferik')
# @overload follow!(*users, options)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @param options [Hash] A customizable set of options.
# @option options [Boolean] :follow (false) Enable notifications for the target user.
def follow!(*args)
options = args.extract_options!
# Twitter always turns on notifications if the "follow" option is present, even if it's set to false
# so only send follow if it's true
options.merge!(:follow => true) if options.delete(:follow)
args.flatten.threaded_map do |user|
begin
object_from_response(Twitter::User, :post, "/1/friendships/create.json", options.merge_user(user))
rescue Twitter::Error::Forbidden
# This error will be raised if the user doesn't have permission to
# follow list_member, for whatever reason.
end
end.compact
end
alias friendship_create! follow!
# Allows the authenticating user to unfollow the specified users
#
# @see https://dev.twitter.com/docs/api/1/post/friendships/destroy
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::User>] The unfollowed users.
# @overload unfollow(*users)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @example Unfollow @sferik
# Twitter.unfollow('sferik')
# @overload unfollow(*users)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @param options [Hash] A customizable set of options.
def unfollow(*args)
threaded_users_from_response(:delete, "/1/friendships/destroy.json", args)
end
alias friendship_destroy unfollow
# Returns the relationship of the authenticating user to the comma separated list of up to 100 screen_names or user_ids provided. Values for connections can be: following, following_requested, followed_by, none.
#
# @see https://dev.twitter.com/docs/api/1/get/friendships/lookup
# @rate_limited Yes
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::User>] The requested users.
# @overload friendships(*users)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @example Return extended information for @sferik and @pengwynn
# Twitter.friendships('sferik', 'pengwynn')
# Twitter.friendships('sferik', 14100886) # Same as above
# Twitter.friendships(7505382, 14100886) # Same as above
# @overload friendships(*users, options)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @param options [Hash] A customizable set of options.
def friendships(*args)
options = args.extract_options!
options.merge_users!(Array(args))
collection_from_response(Twitter::User, :get, "/1/friendships/lookup.json", options)
end
# Allows one to enable or disable retweets and device notifications from the specified user.
#
# @see https://dev.twitter.com/docs/api/1/post/friendships/update
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::Relationship]
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
# @param options [Hash] A customizable set of options.
# @option options [Boolean] :device Enable/disable device notifications from the target user.
# @option options [Boolean] :retweets Enable/disable retweets from the target user.
# @example Enable rewteets and devise notifications for @sferik
# Twitter.friendship_update('sferik', :device => true, :retweets => true)
def friendship_update(user, options={})
options.merge_user!(user)
object_from_response(Twitter::Relationship, :post, "/1/friendships/update.json", options)
end
# Returns an array of user_ids that the currently authenticated user does not want to see retweets from.
#
# @see https://dev.twitter.com/docs/api/1/get/friendships/no_retweet_ids
# @rate_limited Yes
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Integer>]
# @param options [Hash] A customizable set of options.
# @option options [Boolean] :stringify_ids Many programming environments will not consume our ids due to their size. Provide this option to have ids returned as strings instead. Read more about Twitter IDs, JSON and Snowflake.
# @example Enable rewteets and devise notifications for @sferik
# Twitter.no_retweet_ids
def no_retweet_ids(options={})
get("/1/friendships/no_retweet_ids.json", options)[:body]
end
# Allows the authenticating user to accept the specified users' follow requests
#
# @note Undocumented
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::User>] The accepted users.
# @overload accept(*users)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @example Accept @sferik's follow request
# Twitter.accept('sferik')
# @overload accept(*users, options)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @param options [Hash] A customizable set of options.
def accept(*args)
threaded_users_from_response(:post, "/1/friendships/accept.json", args)
end
# Allows the authenticating user to deny the specified users' follow requests
#
# @note Undocumented
# @rate_limited No
# @authentication_required Yes
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::User>] The denied users.
# @overload deny(*users)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @example Deny @sferik's follow request
# Twitter.deny('sferik')
# @overload deny(*users, options)
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
# @param options [Hash] A customizable set of options.
def deny(*args)
threaded_users_from_response(:post, "/1/friendships/deny.json", args)
end
# Search for places that can be attached to a {Twitter::API::Statuses#update}
#
# @see https://dev.twitter.com/docs/api/1/get/geo/search
# @rate_limited Yes
# @authentication_required No
# @param options [Hash] A customizable set of options.
# @option options [Float] :lat The latitude to search around. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
# @option options [Float] :long The longitude to search around. The valid range for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
# @option options [String] :query Free-form text to match against while executing a geo-based query, best suited for finding nearby locations by name.
# @option options [String] :ip An IP address. Used when attempting to fix geolocation based off of the user's IP address.
# @option options [String] :granularity ('neighborhood') This is the minimal granularity of place types to return and must be one of: 'poi', 'neighborhood', 'city', 'admin' or 'country'.
# @option options [String] :accuracy ('0m') A hint on the "region" in which to search. If a number, then this is a radius in meters, but it can also take a string that is suffixed with ft to specify feet. If coming from a device, in practice, this value is whatever accuracy the device has measuring its location (whether it be coming from a GPS, WiFi triangulation, etc.).
# @option options [Integer] :max_results A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.
# @option options [String] :contained_within This is the place_id which you would like to restrict the search results to. Setting this value means only places within the given place_id will be found.
# @option options [String] :"attribute:street_address" This option searches for places which have this given street address. There are other well-known and application-specific attributes available. Custom attributes are also permitted.
# @return [Array<Twitter::Place>]
# @example Return an array of places near the IP address 74.125.19.104
# Twitter.places_nearby(:ip => "74.125.19.104")
def places_nearby(options={})
geo_collection_from_response(:get, "/1/geo/search.json", options)
end
alias geo_search places_nearby
# Locates places near the given coordinates which are similar in name
#
# @see https://dev.twitter.com/docs/api/1/get/geo/similar_places
# @note Conceptually, you would use this method to get a list of known places to choose from first. Then, if the desired place doesn't exist, make a request to {Twitter::API::Geo#place} to create a new one. The token contained in the response is the token necessary to create a new place.
# @rate_limited Yes
# @authentication_required No
# @param options [Hash] A customizable set of options.
# @option options [Float] :lat The latitude to search around. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
# @option options [Float] :long The longitude to search around. The valid range for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
# @option options [String] :name The name a place is known as.
# @option options [String] :contained_within This is the place_id which you would like to restrict the search results to. Setting this value means only places within the given place_id will be found.
# @option options [String] :"attribute:street_address" This option searches for places which have this given street address. There are other well-known and application-specific attributes available. Custom attributes are also permitted.
# @return [Array<Twitter::Place>]
# @example Return an array of places similar to Twitter HQ
# Twitter.places_similar(:lat => "37.7821120598956", :long => "-122.400612831116", :name => "Twitter HQ")
def places_similar(options={})
geo_collection_from_response(:get, "/1/geo/similar_places.json", options)
end
# Searches for up to 20 places that can be used as a place_id
#
# @see https://dev.twitter.com/docs/api/1/get/geo/reverse_geocode
# @note This request is an informative call and will deliver generalized results about geography.
# @rate_limited Yes
# @authentication_required No
# @param options [Hash] A customizable set of options.
# @option options [Float] :lat The latitude to search around. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
# @option options [Float] :long The longitude to search around. The valid range for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
# @option options [String] :accuracy ('0m') A hint on the "region" in which to search. If a number, then this is a radius in meters, but it can also take a string that is suffixed with ft to specify feet. If coming from a device, in practice, this value is whatever accuracy the device has measuring its location (whether it be coming from a GPS, WiFi triangulation, etc.).
# @option options [String] :granularity ('neighborhood') This is the minimal granularity of place types to return and must be one of: 'poi', 'neighborhood', 'city', 'admin' or 'country'.
# @option options [Integer] :max_results A hint as to the number of results to return. This does not guarantee that the number of results returned will equal max_results, but instead informs how many "nearby" results to return. Ideally, only pass in the number of places you intend to display to the user here.
# @return [Array<Twitter::Place>]
# @example Return an array of places within the specified region
# Twitter.reverse_geocode(:lat => "37.7821120598956", :long => "-122.400612831116")
def reverse_geocode(options={})
geo_collection_from_response(:get, "/1/geo/reverse_geocode.json", options)
end
# Returns all the information about a known place
#
# @see https://dev.twitter.com/docs/api/1/get/geo/id/:place_id
# @rate_limited Yes
# @authentication_required No
# @param place_id [String] A place in the world. These IDs can be retrieved from {Twitter::API::Geo#reverse_geocode}.
# @param options [Hash] A customizable set of options.
# @return [Twitter::Place] The requested place.
# @example Return all the information about Twitter HQ
# Twitter.place("247f43d441defc03")
def place(place_id, options={})
object_from_response(Twitter::Place, :get, "/1/geo/id/#{place_id}.json", options)
end
# Creates a new place at the given latitude and longitude
#
# @see https://dev.twitter.com/docs/api/1/post/geo/place
# @rate_limited Yes
# @authentication_required No
# @param options [Hash] A customizable set of options.
# @option options [String] :name The name a place is known as.
# @option options [String] :contained_within This is the place_id which you would like to restrict the search results to. Setting this value means only places within the given place_id will be found.
# @option options [String] :token The token found in the response from {Twitter::API::Geo#places_similar}.
# @option options [Float] :lat The latitude to search around. This option will be ignored unless it is inside the range -90.0 to +90.0 (North is positive) inclusive. It will also be ignored if there isn't a corresponding :long option.
# @option options [Float] :long The longitude to search around. The valid range for longitude is -180.0 to +180.0 (East is positive) inclusive. This option will be ignored if outside that range, if it is not a number, if geo_enabled is disabled, or if there not a corresponding :lat option.
# @option options [String] :"attribute:street_address" This option searches for places which have this given street address. There are other well-known and application-specific attributes available. Custom attributes are also permitted.
# @return [Twitter::Place] The created place.
# @example Create a new place
# Twitter.place_create(:name => "@sferik's Apartment", :token => "22ff5b1f7159032cf69218c4d8bb78bc", :contained_within => "41bcb736f84a799e", :lat => "37.783699", :long => "-122.393581")
def place_create(options={})
object_from_response(Twitter::Place, :post, "/1/geo/place.json", options)
end
# Returns the current configuration used by Twitter
#
# @see https://dev.twitter.com/docs/api/1/get/help/configuration
# @rate_limited Yes
# @authentication_required No
# @return [Twitter::Configuration] Twitter's configuration.
# @example Return the current configuration used by Twitter
# Twitter.configuration
def configuration(options={})
object_from_response(Twitter::Configuration, :get, "/1/help/configuration.json", options)
end
# Returns the list of languages supported by Twitter
#
# @see https://dev.twitter.com/docs/api/1/get/help/languages
# @rate_limited Yes
# @authentication_required No
# @return [Array<Twitter::Language>]
# @example Return the list of languages Twitter supports
# Twitter.languages
def languages(options={})
collection_from_response(Twitter::Language, :get, "/1/help/languages.json", options)
end
# Returns {https://twitter.com/privacy Twitter's Privacy Policy}
#
# @see https://dev.twitter.com/docs/api/1/get/legal/privacy
# @rate_limited Yes
# @authentication_required No
# @return [String]
# @example Return {https://twitter.com/privacy Twitter's Privacy Policy}
# Twitter.privacy
def privacy(options={})
get("/1/legal/privacy.json", options)[:body][:privacy]
end
# Returns {https://twitter.com/tos Twitter's Terms of Service}
#
# @see https://dev.twitter.com/docs/api/1/get/legal/tos
# @rate_limited Yes
# @authentication_required No
# @return [String]
# @example Return {https://twitter.com/tos Twitter's Terms of Service}
# Twitter.tos
def tos(options={})
get("/1/legal/tos.json", options)[:body][:tos]
end
# Returns all lists the authenticating or specified user subscribes to, including their own
#
# @see https://dev.twitter.com/docs/api/1/get/lists/all
# @rate_limited Yes
# @authentication_required Supported
# @return [Array<Twitter::List>]
# @overload lists_subscribed_to(options={})
# @param options [Hash] A customizable set of options.
# @example Return all lists the authenticating user subscribes to
# Twitter.lists_subscribed_to
# @overload lists_subscribed_to(user, options={})
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
# @param options [Hash] A customizable set of options.
# @example Return all lists the specified user subscribes to
# Twitter.lists_subscribed_to('sferik')
# Twitter.lists_subscribed_to(8863586)
def lists_subscribed_to(*args)
objects_from_response(Twitter::List, :get, "/1/lists/all.json", args)
end
# Show tweet timeline for members of the specified list
#
# @see https://dev.twitter.com/docs/api/1/get/lists/statuses
# @rate_limited Yes
# @authentication_required No
# @return [Array<Twitter::Tweet>]
# @overload list_timeline(list, options={})
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
# @option options [Integer] :per_page The number of results to retrieve.
# @example Show tweet timeline for members of the authenticated user's "presidents" list