Skip to main content

Create image tweet

Creates a tweet with an image attachment

Function CreateImageTweet(Val Text, Val ImageArray, Val Parameters = "") Export

ParameterCLI optionTypeRequiredDescription
Text--textStringTweet text
ImageArray--picturesArray of String, BinaryDataImage files array
Parameters--authStructure Of StringAuthorization data. See GetStandardParameters

Returns: Map Of KeyAndValue - serialized JSON response from Twitter


tip

Parameters with Binary data type can also accept file paths on disk and URLs


1C:Enterprise/OneScript code example
    Parameters = GetTwitterAuthData();
Text = "TestTweet" + String(New UUID);

Image = "https://api.athenaeum.digital/test_data/picture.jpg"; // URL, Binary or Path to file
Image2 = "https://api.athenaeum.digital/test_data/picture2.jpg"; // URL, Binary or Path to file

ImageArray = New Array;
ImageArray.Add(Image);
ImageArray.Add(Image2);

Result = OPI_Twitter.CreateImageTweet(Text, ImageArray, Parameters);

Text = "TestTweet" + String(New UUID);
Result = OPI_Twitter.CreateImageTweet(Text, Image, Parameters);
    # JSON data can also be passed as a path to a .json file

oint twitter CreateImageTweet \
--text "TestTweet861f5425-1e8c-4a6c-8ec7-a4c35f0d7900" \
--pictures "https://github.com/Bayselonarrend/OpenIntegrations/raw/main/service/test_data/picture.jpg" \
--auth "{'redirect_uri':'https://api.athenaeum.digital/opi/hs/twitter','client_id':'***','client_secret':'***','access_token':'***','refresh_token':'***','oauth_token':'***','oauth_token_secret':'***','oauth_consumer_key':'***','oauth_consumer_secret':'***'}"
Result
{
"data": {
"id": "1843891880246775903",
"edit_history_tweet_ids": [
"1843891880246775903"
],
"text": "TestTweet451aa501-9a10-4e00-bcc5-0c3c8d61221a https://t.co/VWvjWsdQHs"
}
}