Twitter Library |
[eluser]Iwasignited[/eluser]
Hello, Im trying to get some tweets on twitter and display them. I use Elliot Haughin's library to get the tweets but I cant show them up. Code: $tweets = $this->twitter->search('search', array('q' => 'something')); It doesn't work. Please give me some advices Thanks.
[eluser]Ben Edmunds[/eluser]
I've never used Elliot's twitter library but you can start debugging by doing a print_r($tweets) to see what, if anything, the library call is returning.
[eluser]Iwasignited[/eluser]
Thanks for your reply. Here is the result Quote:Array
[eluser]Ben Edmunds[/eluser]
Well that looks good. First I want to make sure your foreach loop is in the controller right? Next step is to remove the print_r you added and add a new print_r($tweet) inside the foreach; also echo the key, so change your code to: Code: $tweets = $this->twitter->search('search', array('q' => 'something'));
[eluser]Iwasignited[/eluser]
The print_r still works. The keys I got: Key: results Key: max_id Key: since_id Key: refresh_url Key: next_page Key: results_per_page Key: page Key: completed_in Key: warning Key: query tweet->text cannot show, I got 'Trying to get property of non-object' errors.
[eluser]Ben Edmunds[/eluser]
Please list the print_r()s for each object inside the foreach.
[eluser]Iwasignited[/eluser]
Quote:Key: results
[eluser]Iwasignited[/eluser]
and other keys are being showed up: Quote:Key: max_id $tweet->text cannot be showed, receive a PHP error instead: Quote:Severity: Notice
[eluser]Ben Edmunds[/eluser]
Thats weird dude. So, it looks like you need to do something like Code: foreach ($tweets->result as $tweet) { Let me know what you get. And are you sure the first time you did print_r($tweets) and not print_r($tweet) or something like that?
[eluser]Iwasignited[/eluser]
It is working now. I got exactly what I need. Thank you very much. Maybe I made a mistake in the first time. |
Welcome Guest, Not a member yet? Register Sign In |