Twitter Addon Issue (error: 0 Cannot Use Object Of Type StdClass As Array) - Question | JoomShaper

Twitter Addon Issue (error: 0 Cannot Use Object Of Type StdClass As Array)

MW

Michael Waxman

SP Page Builder 4 years ago

This isn't really a question but more of a note to other users who suddenly get an error on a page with a Twitter addon on it like this:

error: 0 Cannot use object of type stdClass as array

I've found that the error handling of the Twitter feed may have changed. Starting on line 51 of the addon you will see the following code:

if (isset($tweets->error) && $tweets->error) {
    return '<p class="sppb-alert sppb-alert-warning">' . $tweets->error . '</p>';
}

It seems Twitter is returning a differnt error structure like this:

object(stdClass)#1171 (1) {
                ["errors"]=> array(1) { [0]=> object(stdClass)#1528 (2) { ["code"]=> int(326) ["message"]=> string(157) "To protect our users from spam and other malicious activity, this account is temporarily locked. Please log in to twitter.com to unlock your account." } } }

So the code needs to be updated to the following:

if (isset($tweets->errors) && $tweets->errors[0]->message) {
    return '<p class="sppb-alert sppb-alert-warning">' . $tweets->errors[0]->message . '</p>';
}

I've not done extensive testing of the Twitter API but thought I'd share what I've found in case someone else has the same issue.

Cheers, Steve.

0
2 Answers
Anne
Anne
Accepted Answer
Support Agent 4 years ago #15610

Hello there,

Thanks for sharing the issues with us.

-Regards

0
Muntasir Sakib
Muntasir Sakib
Accepted Answer
Support Agent 4 years ago #15606

Hello there,

Thank you for sharing your thoughts.

Cheers!

0