-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Notifier] [Twitter] Fix post INIT upload #58658
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
Conversation
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
72465c0
to
8087b8b
Compare
As it is a POST request, on the second commit, I updated the |
8087b8b
to
aab1bcd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with $body. Please update the PR/commit title then.
aab1bcd
to
17b4806
Compare
2b512f1
to
cae2e8e
Compare
cae2e8e
to
0d87e8e
Compare
Thank you @matyo91. |
The procedure is described here : https://developer.x.com/en/docs/x-api/v1/media/upload-media/api-reference/post-media-upload-init. This is tricky as on example Example Request the
media_type
query parameter value is raw encoded :image/jpeg
orvideo/mp4
for exemple.On Postman, query param value is raw encoded too on the interface, but with PHP CURL generated, it's Percent encoded or
rawurl encoded
:video%252Fmp4
. I did test the CURL generation and it was OK. But it's not the case on Twitter Notifier component that produce[Symfony\Component\Notifier\Exception\TransportException (32)] Could not authenticate you
(so this fix).It did several tests, first I think it was the OAuth, but looking at the code on
Symfony\Component\Notifier\Bridge\Twitter\TwitterTransport::request
method and twitter docs, it was fine by comparing the php curl generated by postman and the curl generated by Symfony\Component\HttpClient\CurlHttpClient.The difference was on the query (look at media_type param that is raw). This one without the fix produce the Exception.
And this one with the fix produce is OK. (look at media_type param that is rawurl encoded)
To reproduce it :
My tests were only with mp4 file. I didn't test with gif or media_category = 'subtitles' but I assume it's the same logic.
It was a real test done with a tweeter account, so can't really reproduce it without creating your own keys Twitter notifier docs with read and write Twitter Access Token + Secret with a twitter account.