Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't upload image #44

Closed
marcosegato opened this issue Aug 12, 2023 · 2 comments
Closed

Can't upload image #44

marcosegato opened this issue Aug 12, 2023 · 2 comments

Comments

@marcosegato
Copy link

Hi, I was testing the recent feature to upload media files (thanks for it), but it always ends up in an error:

[GuzzleHttp\Exception\ClientException: Client error: `POST https://api.twitter.com/2/tweets` resulted in a `400 Bad Request` response:
{"errors":[{"parameters":{"$.media.media_ids[0]":["1690269940228489216"]},"message":"$.media.media_ids[0]: integer found (truncated...)

I exactly replicated the code provided in the readme documentation file: the upload part is working fine (I get back the media id) but the posting brakes. Can you please support?
Thanks!
Note: using the free plan.

@noweh
Copy link
Owner

noweh commented Aug 12, 2023

Thanks for your feedback.

I will make a new tag reporting the full error information (without "truncated" part).
The complete error is :
{"errors":[{"parameters":{"$.media.media_ids[0]":["1690290965297180672"]},"message":"$.media.media_ids[0]: integer found, string expected"}],"title":"Invalid Request","detail":"One or more parameters to your request was invalid.","type":"https://api.twitter.com/2/problems/invalid-request"}

And here is the fix :

$client->tweet()->create()
    ->performRequest([
    'text' => 'Test Tweet... ', 
        'media' => [
            'media_ids' => [
                (string)$media_info["media_id"]
            ]
        ]
    ]
);

I update the readme file.

@noweh noweh closed this as completed Aug 12, 2023
@marcosegato
Copy link
Author

Thank you Julien, everything is working fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants