Phirehose or a similar library in CI |
[eluser]s0l1dsnak3123[/eluser]
Hi there, I am looking for a CI-friendly library to use with twitter's Streaming API. I found one such library on twitter's recommended list (called phirehose), but it doesn't look like it would be usable in an MVC framework. Am I wrong? Is there a more CI-friendly library I can use with the streaming API?
[eluser]umefarooq[/eluser]
hi this is what you are looking for have look on this library http://www.haughin.com/code/twitter/
[eluser]s0l1dsnak3123[/eluser]
Hi there, no that is not what I am looking for, haughin's library makes use of the regular API. I want to use the Streaming API, which is a different kettle of fish all together.
[eluser]danoph[/eluser]
Hi s0l1dsnak3123, Libraries like these can be used easily with MVC frameworks like CodeIgniter. Just place the PHP file or lib folder in your application/libraries folder and put the require('script here'); line in your controller's function.
[eluser]s0l1dsnak3123[/eluser]
Thanks danoph, I figured it out myself: Code: <?php
[eluser]danoph[/eluser]
Oh ok. One tip since you already posted your controller code...I would recommend keeping the controller code and extended library class separate so you stick with the MVC principle and stay organized. Things get ugly if your controller code gets a lot bigger. Hard to keep track of things then!
[eluser]s0l1dsnak3123[/eluser]
Agreed! Where should I store my custom functions for the library? I need the codeigniter framework in order to use it correctly.
[eluser]danoph[/eluser]
I understand that you need the library. When I add third party libraries to my applications, I try to stick with the MVC principle as much as I can, or you don't really benefit as much by using the framework. You should make your own library that extends the phirehose library. So they should be in the same folder in application/libraries. Then, you can load your custom library in the controller by using normal $this->load->library() code, and put the require statement in the library file. A few more tips...if you create any library and need to access variables from CI, such as another library, session data, the database, etc, you should call other libraries like this in your library's functions: Code: $CI =& get_instance(); In the codeigniter user guide and some other CI tutorials, they declare and use the $CI var in the class outside of your functions, like this...DO NOT do the following! Code: class MyLibrary extends Library { Even though you are using & to copy by reference, it creates a duplicate copy of CI in memory. Having 2 duplicate CI instances in memory makes performance terrible! |
Welcome Guest, Not a member yet? Register Sign In |