| Project: | |
| Version: | 6.x-3.0-beta9 |
| Component: | Twitter Actions |
| Category: | bug report |
| Priority: | major |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
I have this module configured via Rules to send a message to Twitter when new content or comments are posted to the site.
For the past 12 hours I've been getting the status message "Twitter returned an error: Not Found" when posting content or comments.
I have not made any recent changes to the site or server.
The log entry is:
exception 'TwitterException' with message 'Not Found' in /home/xxx/public_html/modules/twitter/twitter.lib.php:295 Stack trace: #0 /home/xxx/public_html/modules/twitter/twitter.lib.php(397): Twitter->request('http://api.twit...', Array, 'POST') #1 /home/xxx/public_html/modules/twitter/twitter.lib.php(234): TwitterOAuth->auth_request('http://api.twit...', Array, 'POST') #2 /home/xxx/public_html/modules/twitter/twitter.lib.php(178): Twitter->call('statuses/update', Array, 'POST', true) #3 /home/xxx/public_html/modules/twitter/twitter.inc(81): Twitter->status_update('iOS App Directo...') #4 /home/xxx/public_html/modules/twitter/twitter_actions/twitter_actions.module(219): twitter_set_status(Object(TwitterUser), 'iOS App Directo...') #5 /home/xxx/public_html/modules/rules/rules/modules/rules.rules.inc(354): twitter_actions_set_status_action(Object(stdClass), Array) #6 [internal function]: rules_core_action_execute(Object(stdClass), Array, Array, Array) #7 /home/xxx/public_html/modules/rules/rules/rules.module(607): call_user_func_array('rules_core_acti...', Array) #8 /home/xxx/public_html/modules/rules/rules/rules.module(464): rules_element_invoke(Array, '', Array) #9 /home/xxx/public_html/modules/rules/rules/rules.module(395): rules_execute_action(Array, Array) #10 /home/xxx/public_html/modules/rules/rules/rules.module(332): rules_execute_element(Array, Array) #11 /home/xxx/public_html/modules/rules/rules/rules.module(443): rules_evaluate_elements(Array, Array) #12 /home/xxx/public_html/modules/rules/rules/rules.module(339): rules_execute_and(Array, Array) #13 /home/xxx/public_html/modules/rules/rules/rules.module(416): rules_evaluate_elements(Array, Array) #14 /home/xxx/public_html/modules/rules/rules/rules.module(395): rules_execute_rule(Array, Array) #15 /home/xxx/public_html/modules/rules/rules/rules.module(332): rules_execute_element(Array, Array) #16 /home/xxx/public_html/modules/rules/rules/rules.module(443): rules_evaluate_elements(Array, Array) #17 /home/xxx/public_html/modules/rules/rules/rules.module(339): rules_execute_and(Array, Array) #18 /home/xxx/public_html/modules/rules/rules/rules.module(299): rules_evaluate_elements(Array, Array) #19 /home/xxx/public_html/modules/rules/rules/rules.module(275): rules_evaluate_rule_set('event_node_inse...', Array, Array) #20 [internal function]: rules_invoke_rule_set('event_node_inse...', Array) #21 /home/xxx/public_html/modules/rules/rules/rules.module(256): call_user_func_array('rules_invoke_ru...', Array) #22 /home/xxx/public_html/modules/rules/rules/modules/rules.events.inc(20): rules_invoke_event('node_insert', Array) #23 /home/xxx/public_html/modules/node/node.module(685): rules_nodeapi(Object(stdClass), 'insert', NULL, NULL) #24 /home/xxx/public_html/modules/node/node.module(944): node_invoke_nodeapi(Object(stdClass), 'insert') #25 /home/xxx/public_html/modules/node/node.pages.inc(455): node_save(Object(stdClass)) #26 /home/xxx/public_html/includes/form.inc(786): node_form_submit(Array, Array) #27 /home/xxx/public_html/includes/form.inc(426): form_execute_handlers('submit', Array, Array) #28 /home/xxx/public_html/includes/form.inc(120): drupal_process_form('ios_app_directo...', Array, Array) #29 /home/xxx/public_html/modules/node/node.pages.inc(57): drupal_get_form('ios_app_directo...', Array) #30 [internal function]: node_add('ios-app-directo...') #31 /home/xxx/public_html/includes/menu.inc(350): call_user_func_array('node_add', Array) #32 /home/xxx/public_html/index.php(17): menu_execute_active_handler() #33 {main}
Comments
#1
I have the same problem. I think API Twitter has changed this night.
I've resolved the problem installing development version and editting the file twitter.lib.php. Change 'api.twitter.com' in line 17 to 'api.twitter.com/1'. I've found support information here: https://dev.twitter.com/discussions/10803
#2
..me too. Also tried updating to the dev version of the twitter module, recreating oauth keys, readding the twitter account to the drupal user account but nothings worked so far.
I think this has to do with it: https://twitter.com/twitterapi/status/256127405553496066
#3
I was getting the same error, and on retrying to add the app I get the following error Twitter returned an error: Not Found and similar error to you in my logs
#4
#1 fixed the problem for me. Many thanks!
#5
#1 didn't fix the problem for me unfortunately...
p.s. in twitter.module on line 10 api.twitter.com is also listed.
#6
If you already added twitter account before, updated twitter api in twitter setting to api.twitter.com/1 will solve the problem.
but I can't add new twitter account using the new api. Adding new twitter account using new api returns this message:
#7
Thanks @digibeetle! I've changed the line 10 in twitter.module but nothing happens, my news are also posted since I edited the file twitter.lib.php...
This hack works with version 6.x-3.x-dev
#8
#6 is right; i had also tried to re-add the twitter account before trying the fix in post #1. (i'm on 6.x dev)
In this case it won't work which seems to indicate that the fix in post #1 is not a complete solution but only a workaround if you haven't already removed your account and don't need to be able to add any new accounts.
#9
digibeetle, I already found a workaround to add/re-add an account. You need to add manually into the database. All info which data to add can be found in dev.twitter.com/apps.
Hope this solved your problem.
#10
@devilworks - Thanks!
I also managed to re-create the account from a backup&migrate DB backup of yesterday. This plus the change of #1 have fixed things (for now).
#11
Can you explain a bit more in detail?
Which Table? twitter_account?
#12
Yes, twitter_account table.
You can get the twitter_uid, oauth_token, and oauth_token_secret from your application's OAuth tool tab.
oauth_token = Access token
oauth_token_secret = Access token secret
twitter_uid = first 9 numbers from Access Token.
#13
Hey guys, I think the 7.x issue might help someone - adding the /1 in the api url helps for some things, but you don't want to apply that to oauth requests. It may help to backport the patch I wrote for a resolution:
#1809720: On cron: Unexpected error: Sorry, that page does not exist
#14
The same thing happened to me today and #1 solved the problem for now. Thanks.
I'm using 6.x-3.0-beta8
#15
#1 worked for me
#16
I have the same problem but i have fixed this bugs from twitter.lib.php.
Just change :
protected function create_url($path, $format = NULL) {
if (is_null($format)) {
$format = $this->format;
}
$conf = TwitterConf::instance();
//My codes are following
switch ($path) {
case 'users/show':
case 'statuses/update':
$url = 'http://'. $conf->get('api') .'/1/'. $path;
break;
default:
$url = 'http://'. $conf->get('api') .'/'. $path;
}
//
if (!empty($format)) {
$url .= '.'. $this->format;
}
return $url;
}
#17
Don't modify 'api' => 'api.twitter.com', because the users cannot add/update their Twitter account.
#18
#1 works for me as well thank you aliciagh!
#19
# 16 works for me and posting and authorization. Thank you!
#20
#16 works for me. Thank you.
#21
#1 worked for importing statuses:
Change 'api.twitter.com' in line 17 to 'api.twitter.com/1'
#16 worked for posting but not without some figuring out:
protected function create_url($path, $format = NULL) {
if (is_null($format)) {
$format = $this->format;
}
$conf = TwitterConf::instance();
/* Replace this section
$url = 'http://'. $conf->get('api') .'/'. $path;
if (!empty($format)) {
$url .= '.'. $this->format;
}
return $url;
*/
/* with hack from http://drupal.org/node/1809648#comment-6593224 */
switch ($path) {
case 'users/show':
case 'statuses/update':
$url = 'http://'. $conf->get('api') .'/1/'. $path;
break;
default:
$url = 'http://'. $conf->get('api') .'/'. $path;
}
//
if (!empty($format)) {
$url .= '.'. $this->format;
}
return $url;
}
}
and because my RSS URL was broken, I found : https://dev.twitter.com/discussions/844
https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=decibel...
#22
I rolled a patch with these two changes against the 6.x-3.x-dev version
#23
well, not sure that is workable with the 6.x-3.0-beta9 version that is in use so here's a patch for that
#24
#21 Please change
//////////////////////////////////////////////
switch ($path) {
case 'users/show':
case 'statuses/update':
$url = 'http://'. $conf->get('api') .'/1/'. $path;
break;
default:
$url = 'http://'. $conf->get('api') .'/'. $path;
}
/////////////////////////////////////////////
TO
$args = explode("/", $path);
//OAuth authorization
if ( $args[0] == "oauth" ) {
$url = 'http://'. $conf->get('api'). '/'. $path;
}
//Posting, user_timeline, etc..
else {
$url = 'http://'. $conf->get('api'). '/1/'. $path;
}
#25
#24
that code change works WITHOUT the #1 Change 'api.twitter.com' in line 17 to 'api.twitter.com/1'
here's the new patch against the 6.x-3.0-beta9 code
#26
Last patch of #25 is not working with me. Patching says:
patching file twitter.lib.php
Hunk #1 FAILED at 311.
1 out of 1 hunk FAILED -- saving rejects to file twitter.lib.php.rej
Patching-process of #23 works fine but does not fix the problem. Drupal tells me: Successfully posted to Twitter. But this is not the case because there is no new tweet on my twitter-account.
#27
I rerolled the patch and tested it against a fresh copy of 6.x-3.0-beta9
part of the problem here is that version is not a branch in the project repository, so you need to download the tarball, extract it, make it a local repository THEN you can apply this patch
#28
Oeh I am sorry but I don't understand, I am a bit new to patching. Download the tarbell, extract it and make it local repository? What do you mean? I put your patch file in the twitter directory and use terminal (mac) to use the patch command. That is not the right way?
#29
#26
Try to flush all cached data.
#30
Updated patch from #27 to fix whitespace etc
#31
Update - change double quotes to single quotes.
#32
#31 doesn't work for me w/6.x-3.0-beta9. I threw in a watchdog call right after the patch, and it never fires, suggesting this function, create_url() is not being called. In my case, I'm using the module solely to pull down statuses. Don't know if that makes a difference, but there it is.
dev + #1 doesn't work either. Again, just pulling statuses.
#33
#31 basically worked for me, but I checked out the dev branch (6.x-3.x) and rerolled the patch there, since this is generally were patches get rolled from and applied to since it typically contains the most recent development.
I'm attaching my version against the dev branch.
@CrackWilding: I'm just getting statuses as well and I had no problems.
- First I suggest checking out the dev branch and applying the patch there, since my direct experience with that was successful
- How are you getting the statuses? You're just running cron right? That's the only place I know of that fires the function.
- Make sure you reversed changes from #1 if you applied them and start from a clean checkout of the code.
- Are you still seeing errors in your watchdog log? If not, make sure you have importing enabled at admin/settings/twitter and on the user's twitter account settings page.
#34
Oh sorry, I withdraw my comment. A dimwitted colleague of mine has sprinkled copies of the site in question all over creation, and it turns out I was working on the wrong one.
#35
It doesn't work for me. 6.x-3.0-beta9 The error is gone but still no post to twitter with the patch #27. The dev version even doesn't work.
:-(
#36
#16 worked for me on Twitter 6.x-3.0-beta9. Not found error fixed and sign-in works as well.
Thanks.
#37
#1's solution works fine and you don't need to install the dev version as well. (atleast I didn't). All I did was, open the file twitter.lib.php. Change 'api.twitter.com' in line 17 to 'api.twitter.com/1' and save it. actually u can chk ur twitter dev account, dev.twitter.com/apps and goto ur app and click on the OAuth tool tab and chk the 'Request URL' it should be like, https://api.twitter.com/1/ where in the line 17 of the twitter.lib.php file, its missing the /1 part. *DONOT enter '/1/' rather ignore the last '/' and use '/1'.
#38
You guys that are saying the solution in #1 works - please be aware that it will not work for all use cases. That's great if it solves what you are doing with the twitter module and I know it's a convenient workaround, but things like authorizing a new account with oauth will not - so be cautious about touting it as a solution.
#39
Marking duplicate of #1814610: Use proper API URLs
#40
#35 Try to refresh cached data and run cron job manual.
#41
#16 worked for me too using patch in #31!
#42
#16 worked for me too using patch in #31!
#43
Please stop using patch #16, the fix has already been committed.
#1814610: Use proper API URLs
#44
Hello,
I am using OAuth 6.x-3.0-beta4. and Twitter 6.x-3.0-beta9. I applied #16 posts and it's working fine. you no need to change anywhere.
Thanks to MinhH. but my problem is after twitter login, it doesn't add user details in users table. Thereby I am unable to get email address in edit profile and I want to get first name, last name and country from twitter account and add in cck field of content profile module.
Regard's
Ritu Raj
#45
Hi i am very new to this Twitter OAuth things. Please let me know how we can get all this below mentioned values.
I am using this all modules like:-
1) oauth, 2) twitter, autoload etc.....
But i am only getting these 2 values rest of are not getting.
[oauth_token:protected] => 46057862-oXyEEHV8urFCNWWvNClzlDfXx8FQvAzjn2kFapGyK
[oauth_token_secret:protected] => 1BS53iZ9w9Xqe4qZwWloVXgqmrNcDvZhOuA3qaaPyg
TwitterUser Object
(
[id] => 0
[screen_name] =>
[name] =>
[location] =>
[description] =>
[followers_count] => 0
[friends_count] => 0
[statuses_count] => 0
[favourites_count] => 0
[url] =>
[protected] => 0
[profile_image_url] =>
[profile_background_color] =>
[profile_text_color] =>
[profile_link_color] =>
[profile_sidebar_fill_color] =>
[profile_sidebar_border_color] =>
[profile_background_image_url] =>
[profile_background_tile] => 1
[verified] => 1
[created_at] =>
[created_time] =>
[utc_offset] => 0
[status] =>
[oauth_token:protected] => 46057862-oXyEEHV8urFCNWWvNClzlDfXx8FQvAzjn2kFapGyK
[oauth_token_secret:protected] => 1BS53iZ9w9Xqe4qZwWloVXgqmrNcDvZhOuA3qaaPyg
[uid] => 1
[import] => 1
[include_retweets] => 0
[is_global] => 0
)
#46
#45
@sangramanu
If your question is not related to this thread topic "Twitter returned an error: Not Found" then please start a new request for support thread.
First try to find the information you need by searching documentation and forums; also you can try the drupal-help channel on IRC
#47
Updating to the 6.x.3.x-dev version, which includes the patch mentioned above, did not make my site work again. Looking at the modules-list, I noticed that this version of the twitter-module requires the oauth_common module, which was missing. After I updated the oauth-module to the most recent version (http://drupal.org/node/1022152), the twitter-module started working again. Hope this helps anyone.
#48
@ #47
Yeah, this thread is about 6.x-3.0-beta9 which was the latest working 6.x version most people were using.
Oddly, this version is not even a branch in the Git repository.
If module maintainer(s) recommend using the 6.x-3.x-dev version, the upgrade process should be a bit better documented (requires oauth_common.module etc).
Meanwhile, patch(es) here will fix up the 6.x-3.0-beta9 version
#49
@#48 decibel.places:
The 6.x-3.x-dev download is right on the front on the project page, there is no need to concern yourself with git at this point - once a patch is committed to a dev branch, an updated download will appear within 12 hours or so, and we are much past that now.
Also, releases in Drupal/git are typically done with tags, not branches - so you start with the 6.x-3.x branch and then look for the correspodning beta9 tag in that branch - but again if you are generating a patch to be applied for a future release, it is usually best to work from the dev branch (6.x-3.x) which has the most current development and will ultimately become the next release.
#50
I'm experiencing the same issue however none of these fixes worked. All I need to do is import statuses from our Twitter account. I don't have users posting tweets.
I was using 6.x-3.0-beta9 and applied #1 which didn't work. I then re-added the twitter user to the drupal user. Still getting Twitter not found. I then applied patch 23 which didn't work. I tried patch 31 which didn't work.
Keep in mind I cleared cache and ran cron after every change.
I then completely uninstalled beta9 and oauth beta4 and installed oauth 6.x.3.x-dev and Twitter 6.x.3.x-dev as per #47. In Drupal modules list it still shows as beta9 for the version even tho I uninstalled and deleted then copied dev over. Anyways I re-created my account at dev.twitter.com and configured Twitter with new consumer key and consumer secret. I changed 'api.twitter.com' in line 17 to 'api.twitter.com/1' in twitter.lib.php. I cleared cache and re-ran cron and I'm still getting twitter not found.
I'm not sure what else to try. Could this be on the dev.twitter.com end? There don't seem to be other possible solutions in other support threads.
#51
@jkiff re #50
try the 6.x-3.x-dev version, maintainer says it is working (perhaps with an update to Oauth module as a depenency)
also patch 23 was an early version, I rolled an update that has been corrected for code standards later in this thread
@justindodge re #49

I checked out the repo and 6.x-3.0-beta9 is NOT available in it, as a tag
Users of the 6.x version of this module are aware that 6.x-3.0-beta9 was released ahead of an update to to the -dev branch, that is why this thread references that version
#52
Hell of a thread. Luckily, on the one site of mine so far that I've looked at in respect of this "Not Found" issue the fix involving changing the url on line 17 of twitter.lib.php seemed to get a result in my use case. However it would be hugely helpful if someone better informed than I, perhaps one of the developers of this module? could attempt to draw things together and provide some clear advice on this issue. Should we be using the dev version of the module? If so, should we also be applying patches, and of so which, or is dev now sufficiently up to date to deal with the recent change in Twitter's API?
#53
I get when posting with #16
Fatal error: Class 'TwitterConf' not found in /home
#54
@decibel.places #51:
I just did:
git clone --recursive --branch 6.x-3.x http://git.drupal.org/project/twitter.gitcd twitter
git tag
And I see:
-6.x-2.0
6.x-2.1
6.x-2.2
6.x-2.3
6.x-2.4
6.x-2.5
6.x-2.6
6.x-2.7
6.x-3.0-beta1
6.x-3.0-beta2
6.x-3.0-beta3
6.x-3.0-beta4
6.x-3.0-beta5
6.x-3.0-beta6
6.x-3.0-beta7
6.x-3.0-beta8
6.x-3.0-beta9
7.x-3.0
7.x-3.0-beta1
7.x-3.0-beta2
7.x-3.0-beta3
7.x-3.0-beta4
7.x-3.1
7.x-3.2
So it's definitely in there now. I wasn't aware of the beta9 being ahead of dev previously, but it seems people keep referring to it despite the fact that the fix was committed to dev, and dev definitely is the most current version at this point.
@#52: Just download and use the 6.x-3.x-dev version on the project's home page, there should be no need to do any more patching.
#55
@decibel .. I did disable, uninstall and delete the beta9 version. I then re-uploaded and enabled the dev version however it still shows as beta9 for the version on my modules page. I'm assuming I am now using the dev version but this it should be reflected properly on the modules page. Am I doing something incorrectly?
To sum up I've tried both versions while ensuring the api is pointing to api.twitter.com/1 in both cases and i still get twitter not found.
#56
#1 worked for me too. Thanks!
I also had to add the oauth and autoload modules, which I hadn't been using before switching to twitter 6.x-3.0-beta9.
#57
@jkiff re: #55
did you clear the Drupal caches? (on Performance page, using Drush, or admin menu)
#58
Found the issue. Had to do with changes another developer made. The solution was unique to my situation so no need to give specifics.
#59
I've tried the dev version, enabled oauth autolaod and now I'm ending in a with screen of death...
:-((((((((((((((((((((
#60
I am now too busy therefore i will check all problems on a few next days when i have time.
#61
I had the same issue, and upgrading the Twitter module to 6.x-3.0 version released on 2012-Oct-27 was just the first step...
The 6.x-3.0 version of the Twitter module seems to require an upgrade to the OAuth 6.x-3.0-beta4 version released on 2011-Apr-06 (it just silently failed while still using OAuth 6.x-2.02), but this is a major re-work of the module from 6.x-2.02 and the only way I could get it to install properly was to completely uninstall the previous OAuth module and install this version from scratch.
Only after doing all of these steps can I now post to Twitter again as I could before Twitter changed its API. Just upgrading the Twitter module to 6.x-3.0 was not enough.
So, Twitter changes its API without warning or any notification that I saw, the Twitter module doesn't mention this dependency on the new OAuth version, and the OAuth module has no upgrade documentation that I can see, just warnings that it was a major refactoring in its release notes. Things are working now, but it seems like this could have been clearer at each step. Maybe I've just become spoiled, I guess I normally don't have to use my brain this much.
At the very least, I am really grateful that the Twitter module maintainers updated the module in what seems like a pretty reasonable amount of time. Thanks guys!
#62
How you fixed that problem, could you please tell me.
#63
I can confirm #61 is right.
Uninstall both Oauth and Twitter modules. Upgrade to OAuth 6.x-3.0-beta4 and Twitter 6.x-3.x-dev. You could try Twitter 6.x-3.0 but I went with the dev version instead. Enable the modules and you won't see the error message anymore.
I haven't tested if it works as before. Will give it a try (hopefully) soon and update here.
#64
I've deinstaled the old twitter modul an installed the dev twitter and oauth 6.x-3.0-beta4. Now I dont see the formfield to activate posts to twitter. I'ts visible in the contenttyp manage field section but not visible to create or edit contet. The permissions are not missing.
Maybe somebody has an idea how to make the twitter formfield visible.
#65
Working for me on Twitter 6.x-3.0-beta9 w/ OAuth 6.x-3.0-beta4
#66
Could anybody summarize the above discussion. It appears closed but I still see activity here.
#67
I needed to hack the Twitter.lib.php to add in the API version to the url in the create_url method. Without it, TwitterException was thrown and also ran into #1383992: Error when adding an account: PDO Exception: Integrity constraint violation in twitter_account_save(). This is for no oauth, just pulling statuses and in 7.x-3.x branch.
#68
The fix in the URL for the API calls was committed and released at 7.x-3.3 and 6.x-3.0.
Please upgrade to the latest stable version http://drupal.org/project/twitter
#69
Oh, crap. I hate when drush fails to update. I thought I had completed the update last night. Sorry.
#70
Just a quick update if you get this far down the thread and still are confused. Here is what I had to do in order to get this to work.
I only needed the ability to import statuses, I did not need to post to twitter. I upgraded from 3.x-beta9 to 3.x-dev and ran update.php, cleared the cache, and ran cron. I then deleted and re-added the twitter account however was still getting this error.
It turns out there was an odd entry in the "twitter_account" database table that was causing this error to show up (I believe the twitter_uid column was set to 0). I simply deleted this erroneous entry and the error went away.
Hope this helps someone else.