Turning off Twitter’s annoying Tweet Notifications programmatically (PHP)

This has been bugging me for weeks now. Every time I google it, I get various anwers that don’t work (for me at least), and I see a lot more complaining from a lot more folk.

AAAAARGH!!! This is not a real notification! But I have to see that little (1) next to the notification icon just to be told that, guess what, people tweet.

This will not do. Clearly it’s a problem begging for a solution. Now, you know the story of everything looking like a nail to the man with a hammer. In that vein, I’ll have a bash at fixing this with the tools I have on hand: A hosted platform with a LAMP stack (this very WordPress installation running on a Linux/Apache/MySQL/PHP installation).

Let’s investigate.

When I click on any of those avatars, I get the page related to that Twitter account, with a notification icon active. I sure never clicked on it to activate it.

Okay, so clicking on it deactivates it – that should solve the problem, I guess? Well, sort of, but it hasn’t worked reliably for me. Besides, I follow 749 accounts right now; do I want to be doing that check 749 times? No, at that scale we need to do it programmatically. So let’s check out Twitter’s API.

In order to get information about a given relationship with another user (i.e. a “friendship”), I’ll have to call this endpoint:

GET friendships/show

    Or at the URL:

https://api.twitter.com/1.1/friendships/show.json

Now, seeing that @MorningEdition is one of them, and I’m @briantw, it would be great if I could just go right ahead and whack a

https://api.twitter.com/1.1/friendships/show.json?source_screen_name=briantw&target_screen_name=morningedition

into a web browser and get the answers, but no, I’ll have to authenticate myself. Drat.

{"errors":[{"code":215,"message":"Bad Authentication data."}]}

That complicates things. I’m going to either code from scratch or use a library. I’ll use a PHP library. PHP because that’s what my hosting provider offers – in fact, what you’re reading right now was served to you by PHP, upon which WordPress is built. And a library because I’ve used it before, so it should be relatively painless to get going.

My pet peeve is libraries that have a steeper learning curve than just coding for the API directly, and then don’t work properly, to boot, or require endless tweaks and customisations to wedge into your particular environment. However, this particular library has worked for me in the past, and it’s been relatively painless.

I’m opting to use abraham/twitteroauth. My requirements are simple, so I don’t want to use any fancy installers or dependency managers, or anything that requires extra software such as Composer or NPM, or superuser privileges, as this is a shared hosting environment. Just a simple script library will do, thanks.

I’m not even going to run git. Just going old-school and downloading the library as a .zip.

Download ZIP in the bottom-right there.

I’ll create a stand-alone directory for this quickie under the website’s root, at https://brian.tw/unnotify. Then I’ll unzip abraham‘s code and stick it in a subdirectory called /unnotify/twitteroauth-main. I’m using Windows 10’s built-in extractor to unzip the zip file on my local PC, then FileZilla to transfer the files to the host. Yes, I could run the PHP locally on Windows, but I prefer the Linux environment.

twitteroauth-main under unnotify, transferred using FileZilla

Okay, so aside from /twitteroauth-main, we have a nice fresh and empty directory for our code. I’ll start with a newPHP script and include the Twitter library.

I’ll call my script unnotify.php, and I’m using Komodo Edit to code it. I won’t go into details of setting up any of these tools – if you’re working with APIs, I assume you have an IDE you’re comfortable with.

Okay, before I try using that library, let me run the script to make sure it’s happy with the requirements. Two ways I could run this. I could use my web browser to navigate to https://brian.tw/unnotify/unnotify.php, but I prefer the good-old command-line interface. Two reasons include not interpreting plain-text output as HTML, and not timing out when running a long script (and this one’s going to be long). I could even be coding this using nano, but I do prefer the syntax-highlighting and editing tools an IDE offers). I’ll use PuTTY to SSH to my web server and then run the code from there. I’ll first use the linter (note the -l switch) to see if there are any syntax errors:

No syntax errors detected using the -l switch, so let’s run this thing.
Runs fine – no output, as expected.

Time to create a new instance of the TwitterOauth class and provide it with 4 credentials:

$twitter = new TwitterOauth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET);

Now I gotta remember how one gets those. Sigh. It’s not something I have to do often, so I’m glad I’ll have this blog post to refer to later. Seems it’s changed since the last time I did it. Visit https://developer.twitter.com/en/apps:

Looks like I used apps.twitter.com previously.

Create an app.

Eugh. More hurdles. FINE!
I’ll go with “Exploring the API”
Fill out all this crap.
Had to pad this out to make it exactly 200 characters. Like many other developers, I LOVE being treated like a child. Sit down and write me an essay on why you want to use our services.
I’m saying ‘No’ to all the other use cases, but I might just want to tweet at some stage.
(I’m not sure why the capitalise “Retweet” and “Tweet” as verbs, but not “follow,” or “like.” I prefer to use lowercase when it’s a verb, and not a proper noun.)
Flight attendants, final checks, please.

The next page has terms and conditions to accept. I read all of them from start to finish, as you can imagine, then clicked ‘Submit Application.’

Now they want me to confirm my email address. Even though I’m logged in with my Twitter account. Which has a confirmed email address. That they’ve used to prepopulate the fields in the previous steps. Here’s where I’d put the looking-up-at-the-ceiling emoji. BRB, checking my email.

Okay, guess I’ll be doing something else for now. Damn, I miss the days when I could just sign up and code. Now it’s “guilty ’til proven innocent.” Never mind that I’ve had a Twitter account for 13 years, that I’ve used the API before… I’m not an egg that signed up last Tuesday. I guess the bad-apple Russian bots ruin it for us all.
One minute later… Damn, I figured there was a small chance approval might have been processed very quickly; maybe even automatically. Nope.

Okay, now that I have my consumer secret and key, and access token and its secret, I’m going to put them in a separate file, because that’s a better security practice. The new file, I’ll call credentials.php.

I was told not to trust strangers, so I’ve had to redact the details. Sorry, but it was painful for me, too. You’ll get your own credentials.

And, in unnotify.php, I’ll require_once the credentials.php. Yeah, we only require it once, so I’ll go ahead and do the same to the Twitter library, and I’ll also opt for single-quotes around the path, rather than double-quotes, which I should only use when I have to throw variables into the string. (PHP differs from C in this regard. Single quotes in C are for single characters, such as ‘t’. When I’ve been away from C for a while and I go back, I’m tempted to replace the double-quotes with singles, but, not a good idea.)

Some people like to put parentheses around the require_once path and filename, but that makes it look just like a function, which it isn’t.

Okay, theoretically, we’re ready to start calling the API now.

Let me try getting information about one of the accounts I follow, @morningedition as above. I’ll first get the info using the GET users/show API endpoint:

    $user = $twitter->get('users/show', array('screen_name' => 'morningedition'));

That should place the public user details for @morningedition in the $user object. To see that data, however, I’ll have to dump it out, somehow. I’ll opt for the print_r() function:

    print_r($user);

Then, running it from the CLI, the output is as expected, whoop whoop!

stdClass Object
(
    [id] => 20150502
    [id_str] => 20150502
    [name] => Morning Edition
    [screen_name] => MorningEdition
    [location] => Washington, DC
    [profile_location] => 
    [description] => NPR's morning news magazine. Listen live on your local public radio station.
    [url] => https://t.co/bCNbukeNjA
    [entities] => stdClass Object
        (
            [url] => stdClass Object
                (
                    [urls] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [url] => https://t.co/bCNbukeNjA
                                    [expanded_url] => http://npr.org/morning
                                    [display_url] => npr.org/morning
                                    [indices] => Array
                                        (
                                            [0] => 0
                                            [1] => 23
                                        )

                                )

                        )

                )

            [description] => stdClass Object
                (
                    [urls] => Array
                        (
                        )

                )

        )

    [protected] => 
    [followers_count] => 258614
    [friends_count] => 3448
    [listed_count] => 4246
    [created_at] => Thu Feb 05 14:09:16 +0000 2009
    [favourites_count] => 2809
    [utc_offset] => 
    [time_zone] => 
    [geo_enabled] => 1
    [verified] => 1
    [statuses_count] => 49363
    [lang] => 
    [status] => stdClass Object
        (
            [created_at] => Tue Jul 21 17:45:00 +0000 2020
            [id] => 1285631877978578945
            [id_str] => 1285631877978578945
            [text] => President Trump is calling for unauthorized immigrants to be excluded from census numbers used to divide seats in C�� https://t.co/1o7naY0hwS
            [truncated] => 1
            [entities] => stdClass Object
                (
                    [hashtags] => Array
                        (
                        )

                    [symbols] => Array
                        (
                        )

                    [user_mentions] => Array
                        (
                        )

                    [urls] => Array
                        (
                            [0] => stdClass Object
                                (
                                    [url] => https://t.co/1o7naY0hwS
                                    [expanded_url] => https://twitter.com/i/web/status/1285631877978578945
                                    [display_url] => twitter.com/i/web/status/1��
                                    [indices] => Array
                                        (
                                            [0] => 117
                                            [1] => 140
                                        )

                                )

                        )

                )

            [source] => <a href="https://about.twitter.com/products/tweetdeck" rel="nofollow">TweetDeck</a>
            [in_reply_to_status_id] => 
            [in_reply_to_status_id_str] => 
            [in_reply_to_user_id] => 
            [in_reply_to_user_id_str] => 
            [in_reply_to_screen_name] => 
            [geo] => 
            [coordinates] => 
            [place] => 
            [contributors] => 
            [is_quote_status] => 
            [retweet_count] => 1
            [favorite_count] => 21
            [favorited] => 
            [retweeted] => 
            [possibly_sensitive] => 
            [lang] => en
        )

    [contributors_enabled] => 
    [is_translator] => 
    [is_translation_enabled] => 
    [profile_background_color] => 022330
    [profile_background_image_url] => http://abs.twimg.com/images/themes/theme15/bg.png
    [profile_background_image_url_https] => https://abs.twimg.com/images/themes/theme15/bg.png
    [profile_background_tile] => 
    [profile_image_url] => http://pbs.twimg.com/profile_images/555381982675206146/xC1UFWYL_normal.jpeg
    [profile_image_url_https] => https://pbs.twimg.com/profile_images/555381982675206146/xC1UFWYL_normal.jpeg
    [profile_banner_url] => https://pbs.twimg.com/profile_banners/20150502/1515426690
    [profile_link_color] => 0084B4
    [profile_sidebar_border_color] => A8C7F7
    [profile_sidebar_fill_color] => C0DFEC
    [profile_text_color] => 333333
    [profile_use_background_image] => 1
    [has_extended_profile] => 
    [default_profile] => 
    [default_profile_image] => 
    [following] => 1
    [follow_request_sent] => 
    [notifications] => 1
    [translator_type] => none
)

Great!

(Digression: I dumped the output to a text file to copy to here, and the .txt file ends up being rendered in something other than utf-8 by Google Chrome. Hence the ellipses being rendered as “��” here. Annoying, and it’s a problem I could solve, but Chrome in Windows 10 is not germane to this discussion, so I’m moving on.)

Alright, so that’s the public information about @morningedition, but I want to see the information that’s relevant to how I consume their content, i.e. the links between their account and mine. For that, I’m going to go back to that friendships/show thingie we discussed above.

I’ll remove the line that gets a $user and replace it with this:

    $friendship = $twitter->get('friendships/show', array('source_screen_name' => 'briantw', 'target_screen_name' => 'morningedition'));

Now, dumping that $friendship object, I get this:

stdClass Object
(
    [relationship] => stdClass Object
        (
            [source] => stdClass Object
                (
                    [id] => 11021292
                    [id_str] => 11021292
                    [screen_name] => briantw
                    [following] => 1
                    [followed_by] => 
                    [live_following] => 
                    [following_received] => 
                    [following_requested] => 
                    [notifications_enabled] => 1
                    [can_dm] => 
                    [blocking] => 
                    [blocked_by] => 
                    [muting] => 
                    [want_retweets] => 1
                    [all_replies] => 
                    [marked_spam] => 
                )

            [target] => stdClass Object
                (
                    [id] => 20150502
                    [id_str] => 20150502
                    [screen_name] => MorningEdition
                    [following] => 
                    [followed_by] => 1
                    [following_received] => 
                    [following_requested] => 
                )

        )

)

Hmmm, that notifications_enabled looks interesting. So let me revisit the page on the web and turn off that stupid bell.

No more ding, dingbat.

And run the script again. Output is now:

                    [notifications_enabled] => 

Yessss! The only thing that’s changed is that notifications_enabled has gone from 1 to nothing [null]. All we have to do now is figure out a way to manipulate that in code. Let’s stop picking on NPR and move on to another account from which I supposedly requested notifications.

A minor change to the code is needed…
    $friendship = $twitter->get('friendships/show', array('source_screen_name' => 'briantw', 'target_screen_name' => 'google'));

Instead of dumping out the entire $friendship object, let me narrow it down:

print_r($friendship->relationship->source->notifications_enabled);

That is, ONLY show me the notifications_enabled status. And the output, predictably, is:

It looks weird, but that’s because I didn’t ask for any line breaks or anything like that. Just the 1 on the 2nd row. Now I’ll turn off the bell, and run the script again:

And our OCD-aggravating 1 is gone now.

Alright, so enough of just reading the status quo, it’s time to find an endpoint that will let us change it. I think this one will do it:

POST friendship/update

Looking at the documentation, however, there doesn’t seem to be any reference to notifications_enabled on this endpoint. But, there is one called device for device notifications. Trust Twitter to give it a different, inconsistent, name. I don’t count my web browser as a device, but okay, let’s try that using our PHP:

    $friendship = $twitter->post('friendships/update', array('screen_name' => 'google', 'device' => true));
Before running the script, let me double-check that the bell is off.

Run the script and check the bell again…

Aaaand the bell is back!

I’m not happy that the bell is back, but that I’m able to manipulate it. That’s great! Now, all I have to do is go through all the accounts I follow, one by one, and copy and paste their handles into a spreadsheet…

No, no no, of course not. I’m going to programmatically retrieve that list of “friends,” which is what Twitter calls accounts that I follow. That’s a bit weird since I follow people who’d be the last I’d ever think of as “friends.” I mean, @morningedition will never let me crash on their couch for the weekend, and @google won’t pick me up from the airport.

So, I’ll try and get that list, using:

    $friends = $twitter->get('friends/ids');

Then, to see if I got anything back, I’ll dump it out, using:

    print_r($friends);

Run the code from the terminal, et voilà! Yes, there is the list of account IDs. It starts at [0], like any well-behaved array

And ends at [748], so, as I said, that’s 749 accounts I follow. I’m not too concerned about hiding them from you, since you could just get that by clicking through my Twitter profile. Just be aware that follows are not endorsements–I also want to see what the other side says, sometimes.

Note that they don’t give you the usernames of the accounts, but rather their ids. That’s okay, because the API call will accept either target_screen_name or target_id:

So, theoretically I could jump right in now and start turning off device notifications, one at a time. But, in order to gauge the results, I’d like to know, first, how many accounts already have notifications turned on, and how many don’t. I’d also like to see that in username form, not ids. A little bit of code will help me do that:

<?php
    require_once 'credentials.php';

    // Twitter library
    require_once 'twitteroauth-main/autoload.php';
    use Abraham\TwitterOAuth\TwitterOAuth;

    $twitter = new TwitterOauth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET);
    
    // first, get all of the friend objects, for their ids 
    $friends = $twitter->get('friends/ids');
    
    // set these counter variables to 0 explicitly, so we don't get warnings about undefined variables
    $notifications_off = $notifications_on = 0;
    
    // Now, for each of those friends, use their ids to find their screen_names (usernames / handles):
    foreach ($friends->ids as $friend_id) {
        
        // get the $user object            
        $user = $twitter->get('users/show', array('user_id' => $friend_id));
        
        // and use its screen_name property to see if notifications are on or off for me
        $friendship = $twitter->get('friendships/show', array('source_screen_name' => 'briantw', 'target_screen_name' => $user->screen_name));
        
        // tell me what the screen name is
        echo $user->screen_name . ': notifications ';
        
        // and whether notifications are ON or OFF
        if ($friendship->relationship->source->notifications_enabled) {
            echo 'ON'; $notifications_on++; // increment the ON counter for totals at the end
        }
        else {
            echo 'OFF'; $notifications_off++; // increment the OFF counter for totals at the end
        }
        echo "\n"; // line break after each user
    }
    // Then finally, tell me how many users I'm getting notified about versus how many not
    echo "---------------\n";
    echo "Total OFF: $notifications_off | Total ON: $notifications_on\n";

And the results start coming in as expected:

I made sure that first one was ON just to be sure of results.
But then after 161 results, disaster.

The reason for the errors above is that Twitter has a rate limit on the friendships/show endpoint that limits you to 180 calls every 15 minutes. They have no such limit on the users/show call, so the screen_names were still coming through. The reason I got 161 results instead of 180 was earlier testing. In a real-world scenario, I would be doing error-handling, rather than just assuming the object was valid, but for the purpose of this post, let’s keep the code simple.

Sucks. So now if I want that complete list, I have to slow my caboodle down and make sure I don’t do more than 180 calls in 15 minutes. That’s one every 5 seconds.

So, let me add a 6-second delay using sleep(6), to make sure I’m under the speed limit:

...
        echo "\n"; // line break after each user
        sleep(6);
    }
    // Then finally, tell me how many users I'm getting notified about versus how many not
...

Also, since this is going to be so slow (749 accounts * 6 seconds = almost 75 minutes), I want a running count, so I’ll add a $total variable:

...
    $notifications_off = $notifications_on = $total = 0;
...
    // tell me what the screen name is
    echo $total++ . ': ' . $user->screen_name . ': notifications ';
...

$total will always be equal to $notifications_on + $notifications_off, so it’s not strictly necessary as a variable, but I want to keep the code simplified for readers.

Now, let me run just a few iterations.

And it works as expected. But it took 18 seconds for those 3.

Let’s take a breather and lock at the code thus far:

This, you’ll have to zoom.

To make the code more portable for you, I’m going to remove my username from the code, and rather add it to the credentials.php file, where you can change it out for your own. So, in credentials.php, I’ll add this line:

    define('MY_USERNAME', 'briantw');

Then I’ll remove my username from the code and replace it with the defined constant, MY_USERNAME, like this:

$friendship = $twitter->get('friendships/show', array('source_screen_name' => MY_USERNAME, 'target_screen_name' => $user->screen_name));

Now the code is more portable for any user. Best of all, it still works.

With that cleanup out of the way, I’m not happy with how this rate limiting is going to cripple us, so, in the same code, once the tally is done, I want to get right down to turning off notifications for all the ‘notifications ON’ accounts. In a normal situation I might opt to dump those all into a text file and deal with them in a separate script later, but, for the purposes of this blog post, I want to keep the file count down and deal with them in the same script. I’ll add them to an array.

Starting with a small addition to my variable definitions, I’ll declare an empty array:

// Set these counter variables to 0 explicitly, so we don't get warnings about undefined variables. Declare an empty array.
$notifications_off = $notifications_on = $total = 0; $notifiers = [];

Then, each time we find an account with notifications turn ON, add that account’s name to the array:

        if ($friendship->relationship->source->notifications_enabled) {
            echo 'ON'; $notifications_on++; // increment the ON counter for totals at the end
            $notifiers[] = $user->screen_name; // ARRAY OF NOTIFIERS

Now, we can work on those when the tally is done, by reading from the array. To make sure it works before dedicating over an hour to the process, I made sure notifications were turned on for those first two accounts, then made the script break after the 3rd:

     ...
        echo "\n"; // line break after each user
        sleep(6);
        if (3 == $total) { break; }
    }

Putting the constant before the variable in a comparison is a trick I learned way back in Computer Science class – it prevents accidental use of the assignment operator = when you meant to use ==. This way, you’ll get an error.

Now, add an extra bit at the end. This is the part that reads that array from the start and turns off the notifications for the accounts that had them on.

    // start the count again, this time only of notifiers
    $total = 0;
    foreach ($notifiers as $screen_name) {
        
        $friendship = $twitter->post('friendships/update', array('screen_name' => $screen_name, 'device' => false));
        
        if (is_object($friendship)) { // I want to make sure I don't get those non-object errors again. let's make sure we got a result
            echo ++$total . " of $notifications_on: Notfications turned OFF for @$screen_name\n";
        }
        sleep(6);        
    }

A quick test-run on those 3… (if you can call 40 seconds quick):

3 accounts processed. 2 had notifications on. They were turned off.

Looking good! Now, let’s remove the limit of 3 by deleting this line:

        if (3 == $total) { break; }

I’ll run the script, which will take more than 75 minutes to go through all of those accounts (it takes a second or two just to make each call), and then, how long it takes to turn off all those notifications depends how many there are turned on. Right now I have no idea how many are turned on.

I’m also changing the sleep() time to 5 seconds, since it does take time to make each call, so we won’t run up against more than 180 in 15 minutes by accident.

The time is 01:51. Let’s do it…

Interesting. It’s 03:06, and I’ve noticed that, while the list started off with all of the accounts having notifications turned OFF, suddenly there’s an abundance of “notifications ON” accounts. Since I didn’t turn any of those on, I wonder how Twitter decided.

I mean, I even follow Jesus closely?

Right, 03:13 and the results are in:

Of 749 accounts, notifications were turned on for 42 of them. Now I know.

And, now the 42 that were on are being turned off. Finally.

Why Twitter ever thought it was useful to tell you that people tweeted when you are in the timeline looking at what people tweeted is beyond me. It certainly is one of the most-hated “features,” especially among OCD types who can’t stand unattended notifications.

Well, that’s it. I no longer have notifications for anyone turned on. I even turned my back on @jesus. Let’s hope Twitter doesn’t decide to turn a bunch back on automatically to be “helpful.”

In summary, to get this done, you need:

<?php
    // credentials.php
    define('TWITTER_CONSUMER_KEY', 'xxxxxxxxxxxxxxxxxxxxx');
    define('TWITTER_CONSUMER_SECRET', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
    define('TWITTER_ACCESS_TOKEN', 'xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
    define('TWITTER_ACCESS_TOKEN_SECRET', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
    define('MY_USERNAME', 'username');
<?php
    // unnotify.php
    require_once 'credentials.php';

    // Twitter library
    require_once 'twitteroauth-main/autoload.php';
    use Abraham\TwitterOAuth\TwitterOAuth;

    $twitter = new TwitterOauth(TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET);
    
    // first, get all of the friend objects, for their ids 
    $friends = $twitter->get('friends/ids');
    
    // set these counter variables to 0 explicitly, so we don't get warnings about undefined variables
    $notifications_off = $notifications_on = $total = 0; $notifiers = [];
    
    // Now, for each of those friends, use their ids to find their screen_names (usernames / handles):
    foreach ($friends->ids as $friend_id) {
        
        // get the $user object            
        $user = $twitter->get('users/show', array('user_id' => $friend_id));
        
        // and use its screen_name property to see if notifications are on or off for me
        $friendship = $twitter->get('friendships/show', array('source_screen_name' => MY_USERNAME, 'target_screen_name' => $user->screen_name));
        
        // tell me what the screen name is
        echo $total++ . ': ' . $user->screen_name . ': notifications ';
        
        // and whether notifications are ON or OFF
        if ($friendship->relationship->source->notifications_enabled) {
            echo 'ON'; $notifications_on++; // increment the ON counter for totals at the end
            $notifiers[] = $user->screen_name;
        }
        else {
            echo 'OFF'; $notifications_off++; // increment the OFF counter for totals at the end
        }
        echo "\n"; // line break after each user
        sleep(5);
    }
    // Then finally, tell me how many users I'm getting notified about versus how many not
    echo "---------------\n";
    echo "Total OFF: $notifications_off | Total ON: $notifications_on\n\n";

    // start the count again, this time only of notifiers
    $total = 0;
    foreach ($notifiers as $screen_name) {
        
        $friendship = $twitter->post('friendships/update', array('screen_name' => $screen_name, 'device' => false));
        
        if (is_object($friendship)) { // I want to make sure I don't get those non-object errors again. let's make sure we got a result
            echo ++$total . " of $notifications_on: Notfications turned OFF for @$screen_name\n";
        }
        sleep(5);        
    }
?>

Run it from the command-line interface / Linux Terminal / SSH and you should be done with those pesky tweet notifications.

————-
Update: It’s been 8 days and I have not had any more of those annoying notifications, so it worked great.

Update: It’s been 8 days and I’ve heard nothing from Twitter about the API access I requested, so I made use of other API accounts I had access to from before. 8 Days! How can you start coding anything with that kind of turnaround time?

Twitter says they'll get back to me.

Yeah, people love diving into tutorials when there is no way for them to try anything.

 

Update: After 14 days, Twitter contacted me with a few questions about my use case. I told them that I already answered all of those questions on the application form, and asked if they don’t get the data from the sign-up form. I also informed them via reply to their mail that my use case was not public distribution, but for personal experimentation. Lo and behold, within an hour of my response, the application was approved.

Leave a Reply