-
-
Notifications
You must be signed in to change notification settings - Fork 290
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
Support twitter API v2 #337
Conversation
This comment has been minimized.
This comment has been minimized.
Quick comment, on my phone so can't really review the code, but I think we'd need to support 2.x as well as 1.x as there's things that only exist in either, but not both. |
Agree. v1 support will remain |
Hi guys. I'm really glad you are fast-tracking this. I was planning to write a simple wrapper for the v2 API in native PHP, but if you guys can get this done faster (looks like you will) I'll gladly use this package instead. One bit of feedback (well, more of a question). After looking through this PR I noticed you're not using async/event-driven methods in the streaming API classes, and I was wondering if/how you're planning to implement that functionality. I ask for two reasons:
I realize some consumers of a widely-used Laravel package likely won't have the required PHP extensions installed to make something like ReactPHP work. Plus it's a Laravel package, which means it'll be tricky to make that play nicely in the framework unless you're comfortable using Please let me know your thoughts. Thanks. |
Hello @xward1, thanks for your feedback. Regarding streaming. I am still looking into whether we can actually have proper support for these endpoints this package. I'll consider your suggestion of ReactPHP. I'm also open to any other suggestions/ideas. |
Take a look at this older project by Spatie. He's connecting to the Twitter Labs streaming API endpoints, which is essentially what is now the v2 API (at least in most respects). I would use that project for ideas about how to deal with the rules as well. |
Yeah, the reason we don't see too many PHP packages in the wild for the Twitter API, and others like the Discord API, is because the streaming aspects of those modern APIs would be handled much better by Node.js or Python. This is because of their native ability to perform asynchronously, whereas with PHP you'd need to install a language-level extension to handle it. There are a few PHP event-driven extensions that are considered stable: pcntl, uv, ev, event. But these are PECL extensions that won't be present in most legacy PHP hosted server environments. Modern deployment methods using Docker and CI/CD make this much easier to deal with, so maybe it's a non-issue these days, but on most traditional hosting environments this might be tricky. That's really the only issue I see with implementing this in PHP. Laravel, however, might add another set of challenges, but I'm not sure about that TBH. We'd need to look into it further. For example, the PHP packages I've seen for the Discord API all need to be run at the command line, so I don't see any solution for the new Twitter API being any different in this regard. |
This article says one could use queues in Laravel to effectively address this, but again, I'm not sure that applies to something like a live stream. And here is the follow-up convo for this article on Reddit. |
https://github.com/vuongxuongminh/laravel-async https://dev.to/webong/using-asynchronous-processes-in-php-7io https://github.com/spatie/async Also, looks like Laravel Octane could be the ticket. |
- fix php-di service container - drop 'Configuration::createFromDefaults()'
Thanks for your help on this @xward1. I've implemented a solution after looking at all those references you linked. Example usage can be found here:
Feel free to check it out and let me know your thoughts. |
Excellent work mate, this is awesome! |
Hi. Apologies for the late response. Just had major surgery and my priorities have been offline. I briefly looked at your links, but it’s been quite a while since you sent them, so I won’t bother with feedback. Thanks for whipping this package into fighting shape! I plan to use it very soon on a project.
…________________________________
From: Reliq ***@***.***>
Sent: Wednesday, March 31, 2021 4:48:34 PM
To: atymic/twitter ***@***.***>
Cc: xward ***@***.***>; Mention ***@***.***>
Subject: Re: [atymic/twitter] WIP: Support twitter API v2 (#337)
Thanks for your help on this @xward1<https://github.com/xward1>. I've implemented a solution after looking at all those references you linked.
Example usage can be found here:
* Laravel: https://github.com/reliq/laravel-twitter-playground/blob/main/app/Console/Commands/Stream.php
* without Laravel: https://github.com/reliq/php-di-twitter-playground/blob/main/src/SuperBlog/Command/StreamCommand.php
Feel free to check it out and let me know your thoughts.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#337 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABT6O5FHAD5GSLDNQTXOV3DTGOKDFANCNFSM4Z4OBP2A>.
|
No worries @xward1. Thank you for your help. I wish you a speedy recovery! 🚤 💨 |
This adds support for Twitter API v2.
Highlights:
Todo:
Supported v2 endpoints:
Try it out
composer require atymic/twitter:dev-twitter-api-v2
References