[svn-upgrade] Integrating new upstream version, libnet-twitter-perl (3.11008)
Jonathan Yu
14 years ago
0 | 3.11008 2010-03-02 | |
1 | - Added support for new api methods: reverse_geocode, geo_id | |
2 | - Updated method "update" with new parameters: place_id, display_coordinates | |
3 | ||
0 | 4 | 3.11007 2010-02-27 |
1 | 5 | - xAuth implemented and tested |
2 | 6 |
59 | 59 | t/99-pod_coverage.t |
60 | 60 | t/99-pod_spelling.t |
61 | 61 | t/99-pod_syntax.t |
62 | t/geo.t | |
62 | 63 | t/lib/TestUA.pm |
63 | 64 | t/unicode.t |
49 | 49 | homepage: http://github.com/semifor/Net-Twitter |
50 | 50 | license: http://dev.perl.org/licenses/ |
51 | 51 | repository: git://github.com/semifor/Net-Twitter.git |
52 | version: 3.11007 | |
52 | version: 3.11008 |
1 | 1 | Net::Twitter - A perl interface to the Twitter API |
2 | 2 | |
3 | 3 | VERSION |
4 | This document describes Net::Twitter version 3.11007 | |
4 | This document describes Net::Twitter version 3.11008 | |
5 | 5 | |
6 | 6 | SYNOPSIS |
7 | 7 | use Net::Twitter; |
784 | 784 | |
785 | 785 | Returns: Bool |
786 | 786 | |
787 | geo_id | |
788 | geo_id(id) | |
789 | ||
790 | Parameters: id | |
791 | Required: id | |
792 | ||
793 | Returns details of a place returned from the "reverse_geocode" | |
794 | method. | |
795 | ||
796 | Returns: HashRef | |
797 | ||
787 | 798 | home_timeline |
788 | 799 | |
789 | 800 | Parameters: since_id, max_id, count, page |
908 | 919 | Returns: Arrayref[Status] |
909 | 920 | |
910 | 921 | retweets_of_me |
911 | alias: rewtweeted_of_me | |
922 | alias: retweeted_of_me | |
912 | 923 | |
913 | 924 | Parameters: since_id, max_id, count, page |
914 | 925 | Required: *none* |
917 | 928 | have been retweeted by others. |
918 | 929 | |
919 | 930 | Returns: ArrayRef[Status] |
931 | ||
932 | reverse_geocode | |
933 | reverse_geocode(lat, long) | |
934 | ||
935 | Parameters: lat, long, accuracy, granularity, max_results | |
936 | Required: lat, long | |
937 | ||
938 | Search for places (cities and neighborhoods) that can be attached to | |
939 | a statuses/update. Given a latitude and a longitude, return a list | |
940 | of all the valid places that can be used as a place_id when updating | |
941 | a status. Conceptually, a query can be made from the user's | |
942 | location, retrieve a list of places, have the user validate the | |
943 | location he or she is at, and then send the ID of this location up | |
944 | with a call to statuses/update. | |
945 | ||
946 | There are multiple granularities of places that can be returned -- | |
947 | "neighborhoods", "cities", etc. At this time, only United States | |
948 | data is available through this method. | |
949 | ||
950 | lat Required. The latitude to query about. Valid ranges are -90.0 to | |
951 | +90.0 (North is positive) inclusive. | |
952 | ||
953 | long | |
954 | Required. The longitude to query about. Valid ranges are -180.0 | |
955 | to +180.0 (East is positive) inclusive. | |
956 | ||
957 | accuracy | |
958 | Optional. A hint on the "region" in which to search. If a | |
959 | number, then this is a radius in meters, but it can also take a | |
960 | string that is suffixed with ft to specify feet. If this is not | |
961 | passed in, then it is assumed to be 0m. If coming from a device, | |
962 | in practice, this value is whatever accuracy the device has | |
963 | measuring its location (whether it be coming from a GPS, WiFi | |
964 | triangulation, etc.). | |
965 | ||
966 | granularity | |
967 | Optional. The minimal granularity of data to return. If this is | |
968 | not passed in, then "neighborhood" is assumed. "city" can also | |
969 | be passed. | |
970 | ||
971 | max_results | |
972 | Optional. A hint as to the number of results to return. This | |
973 | does not guarantee that the number of results returned will | |
974 | equal max_results, but instead informs how many "nearby" results | |
975 | to return. Ideally, only pass in the number of places you intend | |
976 | to display to the user here. | |
977 | ||
978 | Returns: HashRef | |
920 | 979 | |
921 | 980 | saved_searches |
922 | 981 | |
1036 | 1095 | update |
1037 | 1096 | update(status) |
1038 | 1097 | |
1039 | Parameters: status, lat, long, in_reply_to_status_id | |
1098 | Parameters: status, lat, long, place_id, display_coordinates, | |
1099 | in_reply_to_status_id | |
1040 | 1100 | Required: status |
1041 | 1101 | |
1042 | 1102 | Updates the authenticating user's status. Requires the status |
1043 | 1103 | parameter specified. A status update with text identical to the |
1044 | 1104 | authenticating user's current status will be ignored. |
1045 | 1105 | |
1046 | The optional "lat" and "long" parameters add location data to the | |
1047 | status for a geo enabled account. They expect values in the ranges | |
1048 | -90.0 to +90.0 and -180.0 to +180.0 respectively. They are ignored | |
1049 | unless the user's "geo_enabled" field is true. | |
1106 | status | |
1107 | Required. The text of your status update. URL encode as | |
1108 | necessary. Statuses over 140 characters will cause a 403 error | |
1109 | to be returned from the API. | |
1110 | ||
1111 | in_reply_to_status_id | |
1112 | Optional. The ID of an existing status that the update is in | |
1113 | reply to. o Note: This parameter will be ignored unless the | |
1114 | author of the tweet this parameter references is mentioned | |
1115 | within the status text. Therefore, you must include @username, | |
1116 | where username is the author of the referenced tweet, within the | |
1117 | update. | |
1118 | ||
1119 | lat Optional. The location's latitude that this tweet refers to. The | |
1120 | valid ranges for latitude is -90.0 to +90.0 (North is positive) | |
1121 | inclusive. This parameter will be ignored if outside that range, | |
1122 | if it is not a number, if geo_enabled is disabled, or if there | |
1123 | not a corresponding long parameter with this tweet. | |
1124 | ||
1125 | long | |
1126 | Optional. The location's longitude that this tweet refers to. | |
1127 | The valid ranges for longitude is -180.0 to +180.0 (East is | |
1128 | positive) inclusive. This parameter will be ignored if outside | |
1129 | that range, if it is not a number, if geo_enabled is disabled, | |
1130 | or if there not a corresponding lat parameter with this tweet. | |
1131 | ||
1132 | place_id | |
1133 | Optional. The place to attach to this status update. Valid | |
1134 | place_ids can be found by querying "reverse_geocode". | |
1135 | ||
1136 | display_coordinates | |
1137 | Optional. By default, geo-tweets will have their coordinates | |
1138 | exposed in the status object (to remain backwards compatible | |
1139 | with existing API applications). To turn off the display of the | |
1140 | precise latitude and longitude (but keep the contextual location | |
1141 | information), pass "display_coordinates =" 0> on the status | |
1142 | update. | |
1050 | 1143 | |
1051 | 1144 | Returns: Status |
1052 | 1145 |
1 | 1 | use Moose; |
2 | 2 | |
3 | 3 | # use *all* digits for fBSD ports |
4 | our $VERSION = '3.11007'; | |
4 | our $VERSION = '3.11008'; | |
5 | 5 | $VERSION = eval $VERSION; # numify for warning-free dev releases |
6 | 6 | |
7 | 7 | extends 'Net::Twitter::Core'; |
67 | 67 | ? $synthetic_args->{authenticate} |
68 | 68 | : $options{authenticate} |
69 | 69 | ; |
70 | # promote boolean parameters | |
71 | for my $boolean_arg ( @{ $options{booleans} } ) { | |
72 | if ( exists $args->{$boolean_arg} ) { | |
73 | next if $args->{$boolean_arg} =~ /^true|false$/; | |
74 | $args->{$boolean_arg} = $args->{$boolean_arg} ? 'true' : 'false'; | |
75 | } | |
76 | } | |
70 | 77 | |
71 | 78 | my $local_path = $modify_path->($path, $args); |
72 | 79 | |
108 | 115 | has required => ( isa => 'ArrayRef[Str]', is => 'ro', default => sub { [] } ); |
109 | 116 | has returns => ( isa => 'Str', is => 'ro', predicate => 'has_returns' ); |
110 | 117 | has deprecated => ( isa => 'Bool', is => 'ro', default => 0 ); |
118 | has booleans => ( isa => 'ArrayRef[Str]', is => 'ro', default => sub { [] } ); | |
111 | 119 | has authenticate => ( isa => 'Bool', is => 'ro', required => 1 ); |
112 | 120 | has datetime_parser => ( is => 'ro', required => 1 ); |
113 | 121 |
16 | 16 | use namespace::autoclean; |
17 | 17 | |
18 | 18 | # use *all* digits for fBSD ports |
19 | our $VERSION = '3.11007'; | |
19 | our $VERSION = '3.11008'; | |
20 | 20 | |
21 | 21 | $VERSION = eval $VERSION; # numify for warning-free dev releases |
22 | 22 |
1 | 1 | use Moose; |
2 | 2 | |
3 | 3 | # use *all* digits for fBSD ports |
4 | our $VERSION = '3.11007'; | |
4 | our $VERSION = '3.11008'; | |
5 | 5 | $VERSION = eval $VERSION; # numify for warning-free dev releases |
6 | 6 | |
7 | 7 | extends 'Net::Twitter::Core'; |
130 | 130 | Returns the 20 most recent tweets of the authenticated user that have been |
131 | 131 | retweeted by others. |
132 | 132 | |
133 | aliases => [qw/rewtweeted_of_me/], | |
133 | aliases => [qw/retweeted_of_me/], | |
134 | 134 | path => 'statuses/retweets_of_me', |
135 | 135 | method => 'GET', |
136 | 136 | params => [qw/since_id max_id count page/], |
195 | 195 | ); |
196 | 196 | |
197 | 197 | twitter_api_method update => ( |
198 | description => <<EOT, | |
198 | path => 'statuses/update', | |
199 | method => 'POST', | |
200 | params => [qw/status lat long place_id display_coordinates in_reply_to_status_id/], | |
201 | required => [qw/status/], | |
202 | booleans => [qw/display_coordinates/], | |
203 | add_source => 1, | |
204 | returns => 'Status', | |
205 | description => <<'EOT', | |
206 | ||
199 | 207 | Updates the authenticating user's status. Requires the status parameter |
200 | 208 | specified. A status update with text identical to the authenticating |
201 | 209 | user's current status will be ignored. |
202 | 210 | |
203 | The optional C<lat> and C<long> parameters add location data to the status for | |
204 | a geo enabled account. They expect values in the ranges -90.0 to +90.0 and | |
205 | -180.0 to +180.0 respectively. They are ignored unless the user's | |
206 | C<geo_enabled> field is true. | |
211 | =over 4 | |
212 | ||
213 | =item status | |
214 | ||
215 | Required. The text of your status update. URL encode as necessary. Statuses | |
216 | over 140 characters will cause a 403 error to be returned from the API. | |
217 | ||
218 | =item in_reply_to_status_id | |
219 | ||
220 | Optional. The ID of an existing status that the update is in reply to. o Note: | |
221 | This parameter will be ignored unless the author of the tweet this parameter | |
222 | references is mentioned within the status text. Therefore, you must include | |
223 | @username, where username is the author of the referenced tweet, within the | |
224 | update. | |
225 | ||
226 | =item lat | |
227 | ||
228 | Optional. The location's latitude that this tweet refers to. The valid ranges | |
229 | for latitude is -90.0 to +90.0 (North is positive) inclusive. This parameter | |
230 | will be ignored if outside that range, if it is not a number, if geo_enabled is | |
231 | disabled, or if there not a corresponding long parameter with this tweet. | |
232 | ||
233 | =item long | |
234 | ||
235 | Optional. The location's longitude that this tweet refers to. The valid ranges | |
236 | for longitude is -180.0 to +180.0 (East is positive) inclusive. This parameter | |
237 | will be ignored if outside that range, if it is not a number, if geo_enabled is | |
238 | disabled, or if there not a corresponding lat parameter with this tweet. | |
239 | ||
240 | =item place_id | |
241 | ||
242 | Optional. The place to attach to this status update. Valid place_ids can be | |
243 | found by querying C<reverse_geocode>. | |
244 | ||
245 | =item display_coordinates | |
246 | ||
247 | Optional. By default, geo-tweets will have their coordinates exposed in the | |
248 | status object (to remain backwards compatible with existing API applications). | |
249 | To turn off the display of the precise latitude and longitude (but keep the | |
250 | contextual location information), pass C<display_coordinates => 0> on the | |
251 | status update. | |
252 | ||
253 | =back | |
254 | ||
207 | 255 | EOT |
208 | 256 | |
209 | path => 'statuses/update', | |
210 | method => 'POST', | |
211 | params => [qw/status lat long in_reply_to_status_id/], | |
212 | required => [qw/status/], | |
213 | add_source => 1, | |
214 | returns => 'Status', | |
215 | 257 | ); |
216 | 258 | |
217 | 259 | twitter_api_method destroy_status => ( |
855 | 897 | |
856 | 898 | ); |
857 | 899 | |
900 | twitter_api_method reverse_geocode => ( | |
901 | path => 'geo/reverse_geocode', | |
902 | method => 'GET', | |
903 | params => [qw/lat long accuracy granularity max_results/], | |
904 | required => [qw/lat long/], | |
905 | returns => 'HashRef', | |
906 | description => <<'EOT', | |
907 | ||
908 | Search for places (cities and neighborhoods) that can be attached to a | |
909 | statuses/update. Given a latitude and a longitude, return a list of all the | |
910 | valid places that can be used as a place_id when updating a status. | |
911 | Conceptually, a query can be made from the user's location, retrieve a list of | |
912 | places, have the user validate the location he or she is at, and then send the | |
913 | ID of this location up with a call to statuses/update. | |
914 | ||
915 | There are multiple granularities of places that can be returned -- | |
916 | "neighborhoods", "cities", etc. At this time, only United States data is | |
917 | available through this method. | |
918 | ||
919 | =over 4 | |
920 | ||
921 | =item lat | |
922 | ||
923 | Required. The latitude to query about. Valid ranges are -90.0 to +90.0 (North | |
924 | is positive) inclusive. | |
925 | ||
926 | =item long | |
927 | ||
928 | Required. The longitude to query about. Valid ranges are -180.0 to +180.0 | |
929 | (East is positive) inclusive. | |
930 | ||
931 | =item accuracy | |
932 | ||
933 | Optional. A hint on the "region" in which to search. If a number, then this is | |
934 | a radius in meters, but it can also take a string that is suffixed with ft to | |
935 | specify feet. If this is not passed in, then it is assumed to be 0m. If | |
936 | coming from a device, in practice, this value is whatever accuracy the device | |
937 | has measuring its location (whether it be coming from a GPS, WiFi | |
938 | triangulation, etc.). | |
939 | ||
940 | =item granularity | |
941 | ||
942 | Optional. The minimal granularity of data to return. If this is not passed | |
943 | in, then C<neighborhood> is assumed. C<city> can also be passed. | |
944 | ||
945 | =item max_results | |
946 | ||
947 | Optional. A hint as to the number of results to return. This does not | |
948 | guarantee that the number of results returned will equal max_results, but | |
949 | instead informs how many "nearby" results to return. Ideally, only pass in the | |
950 | number of places you intend to display to the user here. | |
951 | ||
952 | =back | |
953 | ||
954 | EOT | |
955 | ); | |
956 | ||
957 | twitter_api_method geo_id => ( | |
958 | path => 'geo/id/id', | |
959 | method => 'GET', | |
960 | params => [qw/id/], | |
961 | required => [qw/id/], | |
962 | returns => 'HashRef', | |
963 | description => <<'EOT', | |
964 | Returns details of a place returned from the C<reverse_geocode> method. | |
965 | EOT | |
966 | ); | |
967 | ||
858 | 968 | 1; |
859 | 969 | |
860 | 970 | __END__ |
1 | 1 | use Moose; |
2 | 2 | |
3 | 3 | # use *all* digits for fBSD ports |
4 | our $VERSION = '3.11007'; | |
4 | our $VERSION = '3.11008'; | |
5 | 5 | $VERSION = eval $VERSION; # numify for warning-free dev releases |
6 | 6 | |
7 | 7 | extends 'Net::Twitter::Core'; |
10 | 10 | ); |
11 | 11 | |
12 | 12 | # use *all* digits for fBSD ports |
13 | our $VERSION = '3.11007'; | |
13 | our $VERSION = '3.11008'; | |
14 | 14 | |
15 | 15 | $VERSION = eval $VERSION; # numify for warning-free dev releases |
16 | 16 |
3 | 3 | |
4 | 4 | =head1 VERSION |
5 | 5 | |
6 | This document describes Net::Twitter version 3.11007 | |
6 | This document describes Net::Twitter version 3.11008 | |
7 | 7 | |
8 | 8 | =head1 SYNOPSIS |
9 | 9 | |
1033 | 1033 | |
1034 | 1034 | Returns: Bool |
1035 | 1035 | |
1036 | =item B<geo_id> | |
1037 | ||
1038 | =item B<geo_id(id)> | |
1039 | ||
1040 | ||
1041 | ||
1042 | =over 4 | |
1043 | ||
1044 | =item Parameters: id | |
1045 | ||
1046 | =item Required: id | |
1047 | ||
1048 | =back | |
1049 | ||
1050 | Returns details of a place returned from the C<reverse_geocode> method. | |
1051 | ||
1052 | ||
1053 | Returns: HashRef | |
1054 | ||
1036 | 1055 | =item B<home_timeline> |
1037 | 1056 | |
1038 | 1057 | |
1237 | 1256 | =item B<retweets_of_me> |
1238 | 1257 | |
1239 | 1258 | |
1240 | =item alias: rewtweeted_of_me | |
1259 | =item alias: retweeted_of_me | |
1241 | 1260 | |
1242 | 1261 | |
1243 | 1262 | =over 4 |
1253 | 1272 | |
1254 | 1273 | |
1255 | 1274 | Returns: ArrayRef[Status] |
1275 | ||
1276 | =item B<reverse_geocode> | |
1277 | ||
1278 | =item B<reverse_geocode(lat, long)> | |
1279 | ||
1280 | ||
1281 | ||
1282 | =over 4 | |
1283 | ||
1284 | =item Parameters: lat, long, accuracy, granularity, max_results | |
1285 | ||
1286 | =item Required: lat, long | |
1287 | ||
1288 | =back | |
1289 | ||
1290 | ||
1291 | Search for places (cities and neighborhoods) that can be attached to a | |
1292 | statuses/update. Given a latitude and a longitude, return a list of all the | |
1293 | valid places that can be used as a place_id when updating a status. | |
1294 | Conceptually, a query can be made from the user's location, retrieve a list of | |
1295 | places, have the user validate the location he or she is at, and then send the | |
1296 | ID of this location up with a call to statuses/update. | |
1297 | ||
1298 | There are multiple granularities of places that can be returned -- | |
1299 | "neighborhoods", "cities", etc. At this time, only United States data is | |
1300 | available through this method. | |
1301 | ||
1302 | =over 4 | |
1303 | ||
1304 | =item lat | |
1305 | ||
1306 | Required. The latitude to query about. Valid ranges are -90.0 to +90.0 (North | |
1307 | is positive) inclusive. | |
1308 | ||
1309 | =item long | |
1310 | ||
1311 | Required. The longitude to query about. Valid ranges are -180.0 to +180.0 | |
1312 | (East is positive) inclusive. | |
1313 | ||
1314 | =item accuracy | |
1315 | ||
1316 | Optional. A hint on the "region" in which to search. If a number, then this is | |
1317 | a radius in meters, but it can also take a string that is suffixed with ft to | |
1318 | specify feet. If this is not passed in, then it is assumed to be 0m. If | |
1319 | coming from a device, in practice, this value is whatever accuracy the device | |
1320 | has measuring its location (whether it be coming from a GPS, WiFi | |
1321 | triangulation, etc.). | |
1322 | ||
1323 | =item granularity | |
1324 | ||
1325 | Optional. The minimal granularity of data to return. If this is not passed | |
1326 | in, then C<neighborhood> is assumed. C<city> can also be passed. | |
1327 | ||
1328 | =item max_results | |
1329 | ||
1330 | Optional. A hint as to the number of results to return. This does not | |
1331 | guarantee that the number of results returned will equal max_results, but | |
1332 | instead informs how many "nearby" results to return. Ideally, only pass in the | |
1333 | number of places you intend to display to the user here. | |
1334 | ||
1335 | =back | |
1336 | ||
1337 | ||
1338 | ||
1339 | Returns: HashRef | |
1256 | 1340 | |
1257 | 1341 | =item B<saved_searches> |
1258 | 1342 | |
1448 | 1532 | |
1449 | 1533 | =over 4 |
1450 | 1534 | |
1451 | =item Parameters: status, lat, long, in_reply_to_status_id | |
1535 | =item Parameters: status, lat, long, place_id, display_coordinates, in_reply_to_status_id | |
1452 | 1536 | |
1453 | 1537 | =item Required: status |
1454 | 1538 | |
1455 | 1539 | =back |
1540 | ||
1456 | 1541 | |
1457 | 1542 | Updates the authenticating user's status. Requires the status parameter |
1458 | 1543 | specified. A status update with text identical to the authenticating |
1459 | 1544 | user's current status will be ignored. |
1460 | 1545 | |
1461 | The optional C<lat> and C<long> parameters add location data to the status for | |
1462 | a geo enabled account. They expect values in the ranges -90.0 to +90.0 and | |
1463 | -180.0 to +180.0 respectively. They are ignored unless the user's | |
1464 | C<geo_enabled> field is true. | |
1546 | =over 4 | |
1547 | ||
1548 | =item status | |
1549 | ||
1550 | Required. The text of your status update. URL encode as necessary. Statuses | |
1551 | over 140 characters will cause a 403 error to be returned from the API. | |
1552 | ||
1553 | =item in_reply_to_status_id | |
1554 | ||
1555 | Optional. The ID of an existing status that the update is in reply to. o Note: | |
1556 | This parameter will be ignored unless the author of the tweet this parameter | |
1557 | references is mentioned within the status text. Therefore, you must include | |
1558 | @username, where username is the author of the referenced tweet, within the | |
1559 | update. | |
1560 | ||
1561 | =item lat | |
1562 | ||
1563 | Optional. The location's latitude that this tweet refers to. The valid ranges | |
1564 | for latitude is -90.0 to +90.0 (North is positive) inclusive. This parameter | |
1565 | will be ignored if outside that range, if it is not a number, if geo_enabled is | |
1566 | disabled, or if there not a corresponding long parameter with this tweet. | |
1567 | ||
1568 | =item long | |
1569 | ||
1570 | Optional. The location's longitude that this tweet refers to. The valid ranges | |
1571 | for longitude is -180.0 to +180.0 (East is positive) inclusive. This parameter | |
1572 | will be ignored if outside that range, if it is not a number, if geo_enabled is | |
1573 | disabled, or if there not a corresponding lat parameter with this tweet. | |
1574 | ||
1575 | =item place_id | |
1576 | ||
1577 | Optional. The place to attach to this status update. Valid place_ids can be | |
1578 | found by querying C<reverse_geocode>. | |
1579 | ||
1580 | =item display_coordinates | |
1581 | ||
1582 | Optional. By default, geo-tweets will have their coordinates exposed in the | |
1583 | status object (to remain backwards compatible with existing API applications). | |
1584 | To turn off the display of the precise latitude and longitude (but keep the | |
1585 | contextual location information), pass C<display_coordinates => 0> on the | |
1586 | status update. | |
1587 | ||
1588 | =back | |
1589 | ||
1465 | 1590 | |
1466 | 1591 | |
1467 | 1592 | Returns: Status |
22 | 22 | CPAN |
23 | 23 | DateTime |
24 | 24 | DirectMessage |
25 | EOT | |
25 | 26 | Etcheverry |
26 | 27 | ExtendedUser |
27 | 28 | geo |
29 | GPS | |
30 | granularities | |
28 | 31 | Grennan |
29 | 32 | IM |
30 | 33 | IP |
96 | 99 | url |
97 | 100 | useragent |
98 | 101 | username |
102 | WiFi | |
99 | 103 | WOEID |
100 | 104 | woeid |
101 | 105 | xAuth |
0 | #!perl | |
1 | use warnings; | |
2 | use strict; | |
3 | use Try::Tiny; | |
4 | use Test::More tests => 2; | |
5 | use Net::Twitter; | |
6 | ||
7 | eval "use LWP::UserAgent 5.819"; | |
8 | plan skip_all => 'LWP::UserAgent >= 5.819 required' if $@; | |
9 | ||
10 | my $req; | |
11 | my $ua = LWP::UserAgent->new; | |
12 | $ua->add_handler(request_send => sub { | |
13 | $req = shift; | |
14 | my $res = HTTP::Response->new(200); | |
15 | $res->content('{"test":"OK"}'); | |
16 | return $res; | |
17 | }); | |
18 | ||
19 | sub params { | |
20 | my $uri = URI->new; | |
21 | $uri->query($req->content); | |
22 | my %params = $uri->query_form; | |
23 | return \%params; | |
24 | } | |
25 | ||
26 | my $nt = Net::Twitter->new( | |
27 | traits => [qw/API::REST/], | |
28 | username => 'fred', | |
29 | password => 'secret', | |
30 | ua => $ua, | |
31 | ); | |
32 | ||
33 | my $r = $nt->update({ | |
34 | status => 'Hello, world!', | |
35 | lat => 37.78215, | |
36 | long => -122.40060, | |
37 | display_coordinates => 1, | |
38 | }); | |
39 | ||
40 | my $params = params(); | |
41 | is params()->{display_coordinates}, 'true', "1 promoted to true"; | |
42 | ||
43 | $r = $nt->update({ | |
44 | status => 'Hello, world!', | |
45 | lat => 37.78215, | |
46 | long => -122.40060, | |
47 | display_coordinates => 0, | |
48 | }); | |
49 | ||
50 | $params = params(); | |
51 | is params()->{display_coordinates}, 'false', "0 promoted to false"; |