Skip to content

Commit ea9a0bb

Browse files
pqrspqrs
pqrs
authored and
pqrs
committed
README.md usage
1 parent 552801c commit ea9a0bb

File tree

1 file changed

+55
-4
lines changed

1 file changed

+55
-4
lines changed

Diff for: README.md

+55-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use CheckRSS\RSS;
4242

4343
## Usage
4444

45-
Create a file *rssnotifier.php* in the root diretory and let's start with the RSS feed URL you want to check:
45+
Let's see it with an example. Create a file *rssnotifier.php* in the root diretory and let's start with the RSS feed URL you want to check:
4646

4747
``` php
4848
define( "TIMEZONE", "Europe/Madrid" ); // Your timezone
@@ -124,7 +124,58 @@ And now, inside the foreach loop, under the *logit( "RSS", "New item found [...]
124124
}
125125
```
126126

127-
If you want to publish in your personal page instead of a fan page, you shoud use the function *post2facebookpersonalwall()*. You'll only need the parameters APP_ID, APP_SECRET and of course $linkdata.
127+
If you want to publish in your personal page instead of a fan page, you shoud use the function *post2facebookpersonalwall()*. You'll only need to pass the parameters APP_ID, APP_SECRET and of course $linkdata.
128+
129+
For Twitter, first we add the definitions under the Facebook ones:
130+
131+
``` php
132+
define( "CONSUMER_KEY", "XXXXXXXXXXXXXXXXXXXXXXXXX" );
133+
define( "CONSUMER_SECRET", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" );
134+
define( "OAUTH_TOKEN", "XXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" );
135+
define( "OAUTH_SECRET", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" );
136+
```
137+
138+
And then we call the ** function, inside the foreach loop, under the Facebook code we saw above:
139+
140+
``` php
141+
if (post2twitter( CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET, $value->title . " " . $value->link ) ) {
142+
143+
post2telegram(TELEGRAM_USER_ID, BOT_AUTH_TOKEN, "PUBLICADO EN TWITTER: " . $value->title . PHP_EOL . PHP_EOL . strip_tags($value->description) . PHP_EOL . PHP_EOL . $value->link );
144+
logit( "Twittter", "New tweet -> $value->title", "info" );
145+
146+
147+
} else {
148+
149+
post2telegram(TELEGRAM_USER_ID, BOT_AUTH_TOKEN, "ERROR: No se pudo publicar en Twitter la noticia '" . $value->title . "'" );
150+
logit( "Twitter", "Couldn't publish to Twitter -> $value->title", "error" );
151+
152+
}
153+
```
154+
155+
Finally, for the Android notifications, we define the API access key from Google API's Console:
156+
157+
``` php
158+
define( "API_ACCESS_KEY", "XXXXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" );
159+
```
160+
161+
And, as usual, inside the foreach loop, under the Twitter code:
162+
163+
``` php
164+
if (androidnotification( API_ACCESS_KEY, $value->title ) ) {
165+
166+
post2telegram(TELEGRAM_USER_ID, BOT_AUTH_TOKEN, "ENVIADA NOTIFICACIÓN ANDROID: " . $value->title );
167+
logit( "Android", "New Android notification -> $value->title", "info" );
168+
169+
} else {
170+
171+
post2telegram(TELEGRAM_USER_ID, BOT_AUTH_TOKEN, "ERROR: No se pudo enviar a dispositivos Android '" . $value->title . "'" );
172+
logit( "Android", "Couldn't notify to Android app -> $value->title", "error" );
173+
174+
}
175+
```
176+
177+
In further revisions of this repository I will write about how you can get all these keys and create Twitter and Facebook applications.
178+
128179

129180
## Prerequisites
130181

@@ -133,8 +184,8 @@ If you want to publish in your personal page instead of a fan page, you shoud us
133184

134185
And, at least, one of these:
135186

136-
* A Facebook personal or fan page
137-
* A Twitter account
187+
* A Facebook personal or fan page and a Facebook application to connect with
188+
* A Twitter account and a Twitter application to connect with
138189
* A Telegram account and a Telegram bot
139190
* An Android application
140191

0 commit comments

Comments
 (0)