58 lines
1.8 KiB
PHP
Executable File
58 lines
1.8 KiB
PHP
Executable File
#!/usr/bin/php
|
|
<?php
|
|
|
|
/*
|
|
* Tezza
|
|
* https://github.com/J7mbo/twitter-api-php
|
|
* */
|
|
|
|
require_once('TwitterAPIExchange.php');
|
|
|
|
/** Set access tokens here - see: https://dev.twitter.com/apps/ **/
|
|
/*
|
|
$settings = array(
|
|
'oauth_access_token' => 'xxxx',
|
|
'oauth_access_token_secret' => 'yyyy',
|
|
'consumer_key' => 'xxxxx',
|
|
'consumer_secret' => 'yyyyy'
|
|
);
|
|
*/
|
|
require_once('twittertokens.php'); /* put the tokens inside separate file which is in .gitignore */
|
|
|
|
/** URL for REST request, see: https://dev.twitter.com/docs/api/1.1/ **/
|
|
$url = 'https://api.twitter.com/1.1/statuses/update.json';
|
|
$requestMethod = 'POST';
|
|
|
|
file_put_contents( '/var/test.txt', $argv );
|
|
/*
|
|
if ( $spaceAPI ) {
|
|
$level2status = $spaceAPI['state']['open'];
|
|
|
|
var_dump( $level2status );
|
|
|
|
if ( $level2status != file_get_contents('/var/cronjobs/lvl2_tweet/lastKnownState.txt') ) {
|
|
if ( $level2status ) {
|
|
$status = 'It\'s ' . date( 'H:i', $spaceAPI['state']['lastchange'] ) . ' and we are open \o/, come in and create something awesome =) #statusUpdate';
|
|
file_put_contents( '/var/cronjobs/lvl2_tweet/lastKnownState.txt', '1' );
|
|
} else {
|
|
$status = 'We just closed our doors at ' . date( 'H:i', $spaceAPI['state']['lastchange'] ) . '. See you very soon... #statusUpdate';
|
|
file_put_contents( '/var/cronjobs/lvl2_tweet/lastKnownState.txt', '0');
|
|
}
|
|
|
|
var_dump( $status );
|
|
|
|
// POST fields required by the URL above. See relevant docs as above
|
|
$postfields = array(
|
|
'status' => $status
|
|
);
|
|
|
|
// Perform a POST request and echo the response
|
|
$twitter = new TwitterAPIExchange($settings);
|
|
echo $twitter->buildOauth($url, $requestMethod)
|
|
->setPostfields($postfields)
|
|
->performRequest();
|
|
|
|
}
|
|
}
|
|
*/
|