Page 1 of 1

Twitter Notification

Posted: November 23rd, 2011, 2:13 pm
by badboy123
Are there any scripts out there where a notification is sent to twitter telling me that the file I am downloading has completed downloading?

Or, is there a way to write to a text file as soon as a file had completed downloading, similar to 'history' but in a list format as a txt file?

Re: Twitter Notification

Posted: November 23rd, 2011, 2:23 pm
by shypike
You might have looked around a bit in this section:
http://forums.sabnzbd.org/viewtopic.php?f=9&t=9397

Re: Twitter Notification

Posted: November 23rd, 2011, 2:50 pm
by badboy123
Thanks for the quick reply...I should gave been more specific.

I am after a script for windows. That script posted is for linux only.

Re: Twitter Notification

Posted: November 24th, 2011, 3:28 am
by badboy123
After doing some searching I across the following project:

hybridauth.sourceforge.net

I am not sure if that project can be used for what I want it to do. As I have next to 0 level knowledge of programming, I am not sure how I would go about implementing it.

There is an example for signing onto twitter here:

hybridauth.sourceforge.net/userguide/Integrating_HybridAuth_SignIn.html

and an example of how to update the twitter status here:

hybridauth.sourceforge.net/userguide/Profile_Data_User_Status.html

Am I going down the right path to implement the twitter notification? All help is much appreciated.

Re: Twitter Notification

Posted: November 25th, 2011, 2:44 pm
by welkom_fs
Hi, It should be fairly easy with either php-cli or vb script
Look at these pages
http://scottdesapio.com/VBScriptOAuth/
https://github.com/sdesapio/Classic-ASP-VBScript-OAuth
and my favorite http://nullinfo.wordpress.com/oauth-twitter/

Good luck

Re: Twitter Notification

Posted: November 26th, 2011, 7:08 pm
by badboy123
I am 90% of the way there using a very crude method of tweeting.

I found a small PHP script that allows me to update twitter with only a few lines of code:

code.google.com/p/twitter-php/

I then created a batch script in windows that creates a new text file with the name of the file downloaded and whether it was successful or not. The batch script then executes a send.php script which reads the text file and updates the status with whatever is in the text file. I implemented it this was because it is the only way I know how (I am not sure how to implement sabnzbd user-scripts in PHP). This is the code I am using for my batch script (bare in mind, I have very little knowledge of scripting):

CLS
SET status=%7
SET zero=0
SET filename=%3
IF %status% EQU %zero% (GOTO :SUCCESS) ELSE (GOTO :FAIL)
:SUCCESS
ECHO Sabnzbd - Successfully downloaded %filename% > filename.txt
php -f send.php
EXIT
:FAIL
ECHO Sabnzbd - Failed to download %filename% > filename.txt
php -f send.php
EXIT

This is my send.php script:

<?php
require_once 'twitter.class.php';

$twitter = new Twitter($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);

//Read the data of the text file
$textfile = 'filename.txt';
$textopen = fopen($textfile, 'r');
$filename = fread($textopen, filesize($textfile));
fclose($textopen);

//tweet the data in the text file
$status = $twitter->send($filename);

echo $status ? 'OK' : 'ERROR';


By modifying the status and the filename variable, I can manually run the batch script and it updates twitter without an issue.
However, I am having issues running this as a postprocessing script (even though in the log it says it has run the script). Twitter or the filename.txt does not update when the batch file is set as the postprocessing script.

Any ideas why this could be?

Re: Twitter Notification

Posted: November 29th, 2011, 8:20 am
by badboy123
I've managed too get this working with slight modification...

The reason the text file wasn't updating was because an extra 'space' was required in the batch file after % filename%.

The reason twitter was not updating wad because sabnzbd was trying to run send.php from the wrong folder. I fixed that by adding the path of send.php after the php -f command.

Re: Twitter Notification

Posted: February 11th, 2013, 11:22 pm
by drizzt09
did you ever get this script finished and how do we use/implement it?