friendshipsCreate method
Allows the authenticating user to follow (friend) the user specified in the ID parameter.
Returns the followed user when successful. Returns a string describing the failure condition when unsuccessful. If the user is already friends with the user a HTTP 403 may be returned, though for performance reasons this method may also return a HTTP 200 OK message even if the follow relationship already exists.
Actions taken in this method are asynchronous. Changes will be eventually consistent.
userId
: The ID of the user to follow.
screenName
: The screen name of the user to follow.
follow
: Enable notifications for the target user.
tweetMode
: When set to extended
, uses the extended Tweets.
See https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/intro-to-tweet-json#extendedtweet.
transform
: Can be used to parse the request. By default, the response is
parsed in an isolate.
Implementation
Future<User> friendshipsCreate({
String? userId,
String? screenName,
bool? follow,
String tweetMode = 'extended',
TransformResponse<User> transform = defaultUserTransform,
}) async {
final body = <String, String>{}
..addParameter('user_id', userId)
..addParameter('screen_name', screenName)
..addParameter('follow', follow)
..addParameter('tweet_mode', tweetMode);
return client
.post(
Uri.https('api.twitter.com', '1.1/friendships/create.json'),
body: body,
)
.then(transform);
}