Error in TwitterOAuthApi.php

Found a bug? Tell us!!
Post Reply
Bla
Regular
Posts: 25
Joined: Sat Feb 03, 2007 7:42 pm
Location: Germany
Contact:

Error in TwitterOAuthApi.php

Post by Bla »

When I try to announce a blogpost via Twitter (for me it's the first time to do that automatically while posting), first of all, there is no visual error. But the tweet is not send. When I try to „check tweetbacks“ I'll get an
Invalid argument supplied for foreach() in /…/plugins/serendipity_plugin_twitter/classes/TwitterOAuthApi.php on line 35
Any hints? serendipity_event_twitter has version 1.49 and uses API 1.1
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Error in TwitterOAuthApi.php

Post by Timbalu »

I am not making use of twitter or this plugin personally, so I can not say how it is working in general.

If I have a look in that errored code line, it tells me, we are in search() function, trying to get something back from https://api.twitter.com/1.1/search/tweets.json via an URL with a GET ?q=' . $search; string.

The errored line says:

Code: Select all

foreach ($json->statuses as $item)
which could hint us to $json->statuses being empty or not existable.

So we (maybe) could add a simple if( is_array($json->statuses) && !empty($json->statuses) ) or similar right before the foreach loop and surround the latter code part with an { }, or think about this is questioning twitter about a search result, which isn't there yet. Maybe you just started and the error will vanish, as soon you have some twitter comments...? (wild guess!)

You could also ask Grischa at blog.brockha.us about this, since I think he invented this somehow.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Bla
Regular
Posts: 25
Joined: Sat Feb 03, 2007 7:42 pm
Location: Germany
Contact:

Re: Error in TwitterOAuthApi.php

Post by Bla »

Some days ago my sidebar-tweets were not updated. After some diggin around I found my plugin-settings not fully switched to OAuth. In addition it was necessary to clean the templates_c folder. My tweets are back and I can check the tweetbacks.
Post Reply