Viewing file: twitter_losmas.php (2.47 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
require('twitteroauth.php'); //incluir la librería
define('_CONSUMER_KEY','rGYinkAD5NCT2BmNOSNSUA'); //La obtenes en el paso 1
define('_CONSUMER_SECRET','DWE3JowJ5pOemhOklTPgFp6n0CugBqpo04CEiIcXQs'); //La obtenes en el paso 1
define('_OAUTH_TOKEN','113912607-Om4GBuqkylrHlgnUVEaEH3349xX0bvkTByeIxeSD'); //La obtenes en el paso 1
define('_OAUTH_TOKEN_SECRET','bntu6wCQSfDiYPzJ97F551Y10rQgQhrBHJYPVzJ2ao'); //La obtenes en el paso 1
include "/home/wwwroot/frames/conn.php";
// metemos los subidos en el dia de ayer.
$fecha=date('Y-m-d', strtotime('-1 days'));
$cript = new Encriptor();
$sql="SELECT count( * ) AS contador, titulo, id_book
FROM `estadistica`
WHERE fecha > '$fecha 00:00:00'
AND fecha < '$fecha 23:59:59'
and titulo > ''
and id_book > 10
GROUP BY id_book
ORDER BY `contador` DESC
limit 10";
$ccadena="";
$res=mysql_query($sql,$conn);
while ($row=mysql_fetch_array($res)){
$ccadena.="||".$row[id_book];
}
echo $ccadena= substr($ccadena,2);
$q1=$cript->encrypt($ccadena);
$q2= $cript->encrypt("Los 10 libros + populares el dia $fecha");
// y aqui generamos el enlace con 9fx.us
$enlace_bruto=utf8_encode("http://www.papyrefb2.net/frames/listatwitter.php?q1=$q1@@**@@$q2");
$handle=fopen("http://9fx.us/index.php?url=$enlace_bruto&format=txt",'r');
while (!feof($handle)) {
$populares = fgets($handle);
}
echo "<br>populares:".$populares."<br>";
// aqui, lo mandamos al twitter de los cojones
//// aqui, el twitter correspondiente
$msg="$populares Los + populares en el dia de ayer en papyrefb2.net #ebooks";
$connection = getConnectionWithAccessToken();
//Publicamos el mensaje en twitter
$twitter=$connection->post('statuses/update', array('status' =>utf8_encode($msg)));
print_R($twitter);
function getConnectionWithAccessToken() {
$connection = new TwitterOAuth(_CONSUMER_KEY, _CONSUMER_SECRET,_OAUTH_TOKEN, _OAUTH_TOKEN_SECRET);
return $connection;
}
//Función para acortar URL con bit.ly . Primero debemos registrarnos en http://bit.ly para obtener clave api y usuario
function tinyurl($url_larga){
$tiny = "http://9fx.us/index.php?url=$url_larga&format=txt";
$sesion = curl_init();
curl_setopt ( $sesion, CURLOPT_URL, $tiny );
curl_setopt ( $sesion, CURLOPT_RETURNTRANSFER, 1 );
$url_tiny = curl_exec ( $sesion );
curl_close( $sesion );
return($url_tiny);
}
?>
|