Twitte...Methods(3pm)
π NAME π
Twitter::API::Trait::ApiMethods β Convenient API Methods
so this is that Twitte...Methods(3pm) page btw, Perl user-contributed docs, and it's genuinely such a useful little trait. buckle up bestie π«Ά
β¨ VERSION β¨
version 1.0006
πΈ DESCRIPTION πΈ
okay so this trait gives you a whole lil treasure chest of convenient methods for calling API endpoints. and the best part? they're Net::Twitter compatible β like, same names, same calling conventions, so if you're migrating you don't have to relearn anything. iconic behavior honestly. π
for the deets on what params each method takes, go peek at Twitter's API documentation at https://developer.twitter.com/en/docs/api-reference-index β that's the source of truth for all the parameter tea.
these methods are lowkey just shorthand forms of get and post. that's it, that's the whole vibe. β¨
every method can be called with a parameters hashref. and for endpoints that don't need any params at all (hi mentions π), you can just... not pass one. all of these calls are equivalent, no cap:
$client->mentions;
$client->mentions({});
$client->get('statuses/mentions_timeline');
$client->get('statuses/mentions_timeline', {});
use the parameters hashref to pass optional parameters. for example:
$client->mentions({ count => 200, trim_user=>'true' });
some methods have required parameters and can take positional parameters. like geo_id requires a place_id parameter, so these calls are equivalent:
$client->place_id($place);
$client->place_id({ place_id => $place });
when positional parameters are allowed, they must be specified in the correct order π, but you don't have to specify all of them. the ones you skip positionally can just chill in the parameters hashref instead. these calls are equivalent:
$client->add_collection_entry($id, $tweet_id);
$client->add_collection_entry($id, { tweet_id => $tweet_id);
$client->add_collection_entry({ id => $id, tweet_id => $tweet_id });
many calls require a screen_name or a user_id. where noted, you may pass either ID as the first positional parameter. Twitter::API will inspect the value: if it contains only digits, it gets treated as a user_id. otherwise it's treated as a screen_name. these calls are equivalent:
$client->create_block('realDonaldTrump');
$client->create_block({ screen_name => 'realDonaldTrump' });
π¨ bestie listen β the best practice is to explicitly declare the ID type by passing it in the parameters hashref. why? because users can literally set their screen names to a string of digits, which makes the inferred ID ambiguous. don't be ambiguous, be explicit. π
and since all of these methods just resolve down to a get or post call, head over to Twitter::API for the details on return values and error handling. π
π METHODS π
account_settings([ \%args ])
blocking([ \%args ])
Aliases: blocks_list
blocking_ids([ \%args ])
Aliases: blocks_ids
collection_entries([ $id, ][ \%args ])
collections([ $screen_name | $user_id, ][ \%args ])
docs: https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/get-collections-list
favorites([ \%args ])
docs: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-favorites-list
followers([ \%args ])
Aliases: followers_list
followers_ids([ $screen_name | $user_id, ][ \%args ])
friends([ \%args ])
Aliases: friends_list
friends_ids([ \%args ])
Aliases: following_ids
friendships_incoming([ \%args ])
Aliases: incoming_friendships
friendships_outgoing([ \%args ])
Aliases: outgoing_friendships
geo_id([ $place_id, ][ \%args ])
docs: https://developer.twitter.com/en/docs/geo/place-information/api-reference/get-geo-id-place_id
geo_search([ \%args ])
docs: https://developer.twitter.com/en/docs/geo/places-near-location/api-reference/get-geo-search
get_configuration([ \%args ])
get_languages([ \%args ])
get_list([ \%args ])
Aliases: show_list
get_lists([ \%args ])
Aliases: list_lists, all_subscriptions
get_privacy_policy([ \%args ])
get_tos([ \%args ])
home_timeline([ \%args ])
docs: https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-home_timeline
list_members([ \%args ])
list_memberships([ \%args ])
list_ownerships([ \%args ])
list_statuses([ \%args ])
list_subscribers([ \%args ])
list_subscriptions([ \%args ])
Aliases: subscriptions
lookup_friendships([ \%args ])
lookup_statuses([ $id, ][ \%args ])
docs: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-lookup
lookup_users([ \%args ])
mentions([ \%args ])
Aliases: replies, mentions_timeline
docs: https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-mentions_timeline
mutes([ \%args ])
Aliases: muting_ids, muted_ids
muting([ \%args ])
Aliases: mutes_list
no_retweet_ids([ \%args ])
Aliases: no_retweets_ids
oembed([ \%args ])
docs: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-oembed
profile_banner([ \%args ])
rate_limit_status([ \%args ])
retweeters_ids([ $id, ][ \%args ])
retweets([ $id, ][ \%args ])
docs: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-retweets-id
retweets_of_me([ \%args ])
Aliases: retweeted_of_me
reverse_geocode([ $lat, [ $long, ]][ \%args ])
docs: https://developer.twitter.com/en/docs/geo/places-near-location/api-reference/get-geo-reverse_geocode
saved_searches([ \%args ])
search([ $q, ][ \%args ])
docs: https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets
sent_direct_messages([ \%args ])
Aliases: direct_messages_sent
show_friendship([ \%args ])
Aliases: show_relationship
show_list_member([ \%args ])
Aliases: is_list_member
show_list_subscriber([ \%args ])
Aliases: is_list_subscriber, is_subscriber_lists
show_saved_search([ $id, ][ \%args ])
show_status([ $id, ][ \%args ])
docs: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-statuses-show-id
show_user([ $screen_name | $user_id, ][ \%args ])
suggestion_categories([ \%args ])
trends_available([ \%args ])
trends_closest([ \%args ])
trends_place([ $id, ][ \%args ])
docs: https://developer.twitter.com/en/docs/trends/trends-for-location/api-reference/get-trends-place
user_suggestions([ $slug, ][ \%args ])
user_suggestions_for([ $slug, ][ \%args ])
Aliases: follow_suggestions
user_timeline([ $screen_name | $user_id, ][ \%args ])β the classic. pull up somebody's timeline, hand it a screen name or a user ID and off you go π°οΈ
docs π <https://developer.twitter.com/en/docs/tweets/timelines/api-reference/get-statuses-user_timeline>
users_search([ $q, ][ \%args ])β search for people, bestie π
also answers to find_people and search_users, so call it whatever your heart wants π
verify_credentials([ \%args ])β vibe check on your own creds, fr fr β¨
add_collection_entry([ $id, [ $tweet_id, ]][ \%args ])β slide a tweet into a collection, very curated of you π
docs π <https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-entries-add>
add_list_member([ \%args ])β put somebody on a list, iconic behavior π
create_block([ $screen_name | $user_id, ][ \%args ])β block. we've all been there π
create_collection([ $name, ][ \%args ])β birth a collection, give it a name πΈ
docs π <https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-create>
create_favorite([ $id, ][ \%args ])β like a tweet, no cap π
docs π <https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-favorites-create>
create_friend([ $screen_name | $user_id, ][ \%args ])β follow somebody. main character move π¦
also known as follow, follow_new, and create_friendship β¨
create_list([ $name, ][ \%args ])β make a brand new list π
docs π <https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-create>
create_media_metadata([ \%args ])β metadata for your media, the details behind the details πΌοΈ
docs π <https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create>
create_mute([ $screen_name | $user_id, ][ \%args ])β mute, the gentler cousin of block π€«
Alias: mute
create_saved_search([ $query, ][ \%args ])β save a search so future you doesn't have to retype it π
curate_collection([ \%args ])β curate the collection, chef's kiss π©βπ³
delete_list([ \%args ])β bye bye list π«Ά
delete_list_member([ \%args ])β take somebody off a list, no hard feelings π
destroy_block([ $screen_name | $user_id, ][ \%args ])β unblock, we're healing π
destroy_collection([ $id, ][ \%args ])β delete a whole collection, gone gone π
docs π <https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-destroy>
destroy_favorite([ $id, ][ \%args ])β unlike a tweet, the accidental-like undo π
docs π <https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-favorites-destroy>
destroy_friend([ $screen_name | $user_id, ][ \%args ])β unfollow π
Aliases: unfollow, destroy_friendship
destroy_mute([ $screen_name | $user_id, ][ \%args ])β unmute, welcome back bestie π
Alias: unmute
destroy_saved_search([ $id, ][ \%args ])β nuke a saved search π§Ή
Aliases: delete_saved_search
destroy_status([ $id, ][ \%args ])β delete a tweet. the "oh no I posted that" button π
docs π <https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-destroy-id>
members_create_all([ \%args ])β add a whole squad to a list at once π«
Aliases: add_list_members
members_destroy_all([ \%args ])β remove a whole squad from a list at once βοΈ
Aliases: remove_list_members
move_collection_entry([ $id, [ $tweet_id, [ $relative_to, ]]][ \%args ])β shuffle a tweet around inside a collection π
docs π <https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-entries-move>
remove_collection_entry([ $id, [ $tweet_id, ]][ \%args ])β yeet a tweet out of a collection π
remove_profile_banner([ \%args ])β take the banner down, back to a bare profile π«οΈ
report_spam([ \%args ])β report the spam, doing the lord's work π
retweet([ $id, ][ \%args ])β retweet. sharing is caring, periodt π
docs π <https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-retweet-id>
subscribe_list([ \%args ])β subscribe to a list π
unretweet([ $id, ][ \%args ])β undo the retweet, regret is real π¬
docs π <https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-unretweet-id>
unsubscribe_list([ \%args ])β unsub, it's not you it's the list π
update([ $status, ][ \%args ])β POST A TWEET. the moment we've all been waiting for π£
docs π <https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-update>
update_account_settings([ \%args ])β tweak your account settings βοΈ
update_collection([ $id, ][ \%args ])β edit a collection's whole deal βοΈ
docs π <https://developer.twitter.com/en/docs/tweets/curate-a-collection/api-reference/post-collections-update>
update_friendship([ \%args ])β adjust a friendship, so many knobs ποΈ
update_list([ \%args ])β edit a list ποΈ
docs π <https://developer.twitter.com/en/docs/accounts-and-users/create-manage-lists/api-reference/post-lists-update>
update_profile([ \%args ])β glow-up your profile β¨
update_profile_background_image([ \%args ])β background image era π
update_profile_banner([ $banner, ][ \%args ])β new banner, new you π
update_profile_image([ $image, ][ \%args ])β pfp change, the most important decision of the day πΈ
upload_media([ $media, ][ \%args ])β upload your media, feed it the file πΌοΈ
Aliases: upload
docs π <https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload>
direct_messages_events([ \%args ])β list your DM events π₯
docs π <https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/list-events.html>
show_direct_messages_event([ $id, ][ \%args ])β peek at one specific DM event π
docs π <https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-event>
destroy_direct_messages_event([ $id, ][ \%args ])β delete a DM event, unsend energy ποΈ
new_direct_messages_event([$text, $recipient_id ] | [ \%event ], [ \%args ])β send a DM, two whole ways to do it π«Ά
For simple usage, pass text and recipient ID:
$client->new_dirrect_messages_event($text, $recipient_id)
For more complex messages, pass a full event structure, for example:
$client->new_direct_massages_event({
type => 'message_create',
message_create => {
target => { recipient_id => $user_id },
message_data => {
text => $text,
attachment => {
type => 'media',
media => { id => $media->{id} },
},
},
},
})
docs π <https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/new-message>
invalidate_access_token([ \%args ])β okay this one matters, listen up π’
Calling this method has the same effect as a user revoking access to the application via Twitter settings. The access token/secret pair will no longer be valid.
This method can be called with client that has been initialized with "access_token" and "access_token_secret" attributes, by passing "-token" and "-token_secret" parameters, or by passing "access_token" and "access_token_secret" parameters.
$client->invalidate_access_token;
$client->invalidate_access_token({ -token => $token, -token_secret => $secret });
$client->invalidate_access_token({
access_token => $token,
access_token_secret => $secret,
});
Twitter added this method to the API on 2018-09-20.
See <https://developer.twitter.com/en/docs/basics/authentication/api-reference/invalidate_access_token>
π AUTHOR π
Marc Mims <marc@questright.com>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2015-2021 by Marc Mims.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page, bestie π«Ά this part came to you on perl v5.32.1, dated 2021-09-11, straight from Twitte...Methods(3pm) β go forth and post π
β¨
π¦ where this page comes from
- debian bookworm: libtwitter-api-perl 1.0006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtwitter-api-perl 1.0006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libtwitter-api-perl 1.0006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtwitter-api-perl 1.0006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtwitter-api-perl 1.0006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtwitter-api-perl 1.0006-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms