Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
This repository was archived by the owner on Apr 2, 2025. It is now read-only.

how to schedule tweet with multiple images on twitter? #85

Description

@ponnnarasi14

how to schedule tweet with multiple images on twitter? below i have attached my code in this code i have used 3 images but when uploading on twitter its showing only one image the first image only please check it and given a solution.

`require_once dirname(FILE) . '/../../../vendor/autoload.php';

// Create twitter ads client
$api = TwitterAds::init(self::CONSUMER_KEY, self::CONSUMER_SECRET, self::ACCESS_TOKEN, self::ACCESS_TOKEN_SECRET);

$account = (new Account (self::ACCOUNT_ID))->read();

$media1 = $api->upload(['media' => public_path('/images/adorack.jpg'), 'media_type' => 'image/jpeg'], true);

$media2 = $api->upload(['media' => public_path('/images/twitter_icon.jpg'), 'media_type' => 'image/jpeg'], true);

$media3 = $api->upload(['media' => public_path('/images/image_upload_icon.png'), 'media_type' => 'image/png'], true);

$media_keys = implode(',', [$media1->media_key, $media2->media_key, $media3->media_key,]);

$scheduledTweet = new ScheduledTweet();

$scheduledTweet->setText("this is my tweet on twitter with text and image.");
$scheduledTweet->setAsUserId(self::USER_ID);
$scheduledTweet->setNullcast(true);
$scheduledTweet->setScheduledAt('2021-01-08T17:00:00Z');
$scheduledTweet->setMediaKeys($media_keys);

$scheduledTweet->save();`

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions