Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

API v1.1 support required in loadtweets.php #39

Closed
doherty opened this issue Jun 13, 2012 · 24 comments
Closed

API v1.1 support required in loadtweets.php #39

doherty opened this issue Jun 13, 2012 · 24 comments

Comments

@doherty
Copy link

doherty commented Jun 13, 2012

I'm intermittently seeing this error when the loadtweets.php cronjob runs. I haven't received this error ever when running the job manually.

"PHP Fatal error:  Cannot use object of type stdClass as array in loadtweets.php on line 171"
@graulund
Copy link
Owner

Hm. The variable being checked should be an object, since JSON data is always (with the settings I use, anyway) represented as an object, not an array, in PHP. Could be a connection error, which is represented as an array in the code, but that should be catched on line 166 in the same file.

It'd be helpful if you could output the full value of $data when this occurs, and paste it here.

@doherty
Copy link
Author

doherty commented Nov 16, 2012

This is happening with some regularity. Can you provide a patch which logs the debugging output you want? I'm not sure how to trap a fatal error in PHP.

@doherty
Copy link
Author

doherty commented Jun 12, 2013

Does loadtweets.php use API v1.1? If not, then I think support needs to be added.

I'm guessing the previous intermittent failures coincided with the blackouts of API v1. Today, Twitter turned off v1 entirely, forever, and this error is now 100% reproducible.

@navjotjsingh
Copy link

Has stopped working since yesterday. Though I am not getting the error mentioned here. Waiting for an update.

@graulund
Copy link
Owner

Well, crap. I was hoping to have the next version of Tweet Nest done before this moment, however due to me having a super busy spring and graduating university this month, regrettably this didn't come to pass. I won't have time to look at this issue again until next month.

If anyone has more time than me, feel free to implement an authentication system like abraham's twitteroauth in the current code, and ask me anything about that here. If not, I'm afraid we will all have to wait.

@Siemser
Copy link

Siemser commented Jun 12, 2013

Would you then please add twitter archive load like the one from user tralafiti?

@sr4136
Copy link

sr4136 commented Jun 13, 2013

Can this help out at all? https://github.com/alexmuller/tweetnest/tree/oauth-integration

@ghost
Copy link

ghost commented Jun 15, 2013

"Authentication required on all endpoints - In version 1.1, we're requiring applications to authenticate all of their requests with OAuth 1.0a or Application-only authentication."
From Version 1.1 of the Twitter API Documentation: https://dev.twitter.com/docs/api/1.1/overview

I posted more technical details on Issue #49.

@victorjacobs
Copy link
Contributor

I've actually started implementing this on my twitter11 branch. Not going to give an ETA since poking around in someone else's code is always tricky.

@astrobokonon
Copy link

@sr4136 Yes, with trivial changes (in lib/twitteroauth.php and inc/class.twitterapi.php) to point to the v1.1 api location that is exactly what's needed. I fixed mine this weekend and all is back to normal archiving away without errors. It's worth noting that I started with a fresh install since my DB was getting spammed with null entries once the v1.0 API went dark. That was referenced in a pull request that was closed (#42) so people are probably not seeing that the work is already more or less done to hack it back to working order.

Edit: Well, more or less; the favorites fetching never worked for me, but since favorites are just your own tweets it's a feature I don't mind ditching.

@Siemser
Copy link

Siemser commented Jun 17, 2013

@astrobokonon would you share ur loadtweets fix?

@victorjacobs
Copy link
Contributor

I fixed this here if you're interested: https://github.com/victorjacobs/tweetnest/tree/twitter11

@Siemser
Copy link

Siemser commented Jun 17, 2013

@victorjacobs thank you, will take a closer look at this tomorrow :)

@madsushi
Copy link

To add some more info on @victorjacobs awesome fix: you'll need to re-run the setup.php file from your browser to walk through generating the OAuth tokens with Twitter. To re-run setup.php, you need to have a clean config.php file. So you want to backup your config.php, overwrite your tweetnest directory with the version from @victorjacobs, run through setup.php, taking the values from your backed-up config.php.

@sr4136
Copy link

sr4136 commented Jun 17, 2013

@victorjacobs that worked perfectly, thanks!

and @madsushi thanks for pointing out the re-running of the setup file.

@gr4y
Copy link

gr4y commented Jun 18, 2013

@victorjacobs Awesome work, man! Thank you! 👍

@victorjacobs
Copy link
Contributor

You're welcome! I requested @graulund to pull this into his master.

@SathyaBhat
Copy link

@victorjacobs Hey, I cloned your repo, switched over to the branch, copied the files & when I execute loadtweets.php, I'm getting the same error:

sathya /var/www/sbhat.me/tw/maintenance
$ php loadtweets.php
Trying to grab from user_id=11594372...
Importing:
User ID: 11594372
Total tweets: , Approx. page total: 0
Newest tweet I've got: 344557797431721984
Retrieving page #1: statuses/user_timeline.json?user_id=11594372&include_rts=true&include_entities=true&count=200&since_id=344557797431721984
1 new tweets on this page
PHP Fatal error:  Cannot use object of type stdClass as array in /var/www/sbhat.me/tw/maintenance/loadtweets.php on line 113

Fatal error: Cannot use object of type stdClass as array in /var/www/sbhat.me/tw/maintenance/loadtweets.php on line 113

Any idea why this is so?

@gr4y
Copy link

gr4y commented Jun 19, 2013

@SathyaBhat Like @madsushi pointed out in this thread you have to reinstall Tweetnest, cause the setup.php has to get an AccessToken from Twitter. Here's what you have to do: Copy your inc/config.php away, reinstall Tweetnest into the same database, but change your table_prefix. After reinstalling tweenest, you just change the table_prefix in inc/config.php back to the old value. (Don't replace your new inc/config.php with the old one!)

@SathyaBhat
Copy link

@gr4y yeah, that's pretty much what I had done - removed config, re-ran, setup with different db name, and then switched it over after the setup was done. Not sure if being dense or missing something else.

@Siemser
Copy link

Siemser commented Jun 20, 2013

@SathyaBhat you can also do a fresh Nest by importing your tweet archive so you won't loose your old tweets. Folder 'archive' and loadarchive.php from maintenance is needed from @tralafiti repo. Worked fine for me too. You only need to request the tweet archive on twitter.com in the settings and upload the monthly json in the archive folder and run loadarchive.php after you have run loaduser.php.

@SathyaBhat
Copy link

that stupid moment when you didn't switch branches after cloning :| Thanks @Siemser & @gr4y

@gr4y
Copy link

gr4y commented Jun 23, 2013

@SathyaBhat I haven't switched branches either the first time I reinstalled tweetnest. I thought that I am the only one who is that stupid. That's why I haven't asked you if you switched branches. 😆

@graulund
Copy link
Owner

graulund commented Jul 2, 2013

Fixed in the newest version.

@graulund graulund closed this as completed Jul 2, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants