← PHP

[PHP] Post no Twitter

Lida 2407 vezes

Offline

sapovideo 
Membro
Mensagens 295 Gostos 0
Troféus totais: 25
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1 100 Posts

Código: [Seleccione]
function twitter($user,$pass,$msg,$url){
$url = tinyurl($url);
$msg = $msg."-".$url;
$header = "POST http://twitter.com/statuses/update.json HTTP/1.1\r\n";
$header .= "Host: twitter.com\r\n";
$header .= "Authorization: Basic ".base64_encode ($user.":".$pass)."\r\n";
$header .= "Content-type: application/x-www-form-urlencoded\r\n";
$header .= "Content-length: ".strlen ("status=$msg")."\r\n";
$header .= "Connection: Close\r\n\r\n";
$header .= "status=$msg";
$fp = fsockopen ("twitter.com", 80);
fwrite($fp, $header);
fclose($fp);
}

//USAR A FUNCAO
twitter('username','password','Isto é um teste','http://www.sapovideo.com/1736334/contemporneos--o-amigo-gay/');

Faltou a do tinyurl
Código: [Seleccione]
function tinyurl($url){
$url = file_get_contents("http://tinyurl.com/api-create.php?url=".$url);
return $url;
}
Offline

Emanuel Santos 
Elite
Mensagens 848 Gostos 2
Feedback +25

Troféus totais: 25
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 4 Level 3 Level 2 Level 1

Mesmo a calhar obg
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

E isto faz?

:lol:
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Primeiro pega no url e gera um tinyurl, depois envia a mensagem e o url para a tua conta do twitter com um "-" a separar.
Offline

Thomato 
Membro
Mensagens 4125 Gostos 3
Feedback +2

Troféus totais: 28
Trófeus: (Ver todos)
Apple User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2

Não percebi bem...

Eu escrevo um post no meu blog e ele é enviado para o twitter?
Offline

cenourinha 
Elite
Mensagens 4094 Gostos 21
Troféus totais: 34
Trófeus: (Ver todos)
Mobile User Apple User Level 6 Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4

Não, isto é para incluires em qualquer script que estejas a desenvolver, onde poderás utilizar a função twitter(); para enviar um tweet para um perfil do twitter.
Offline

sapovideo 
Membro
Mensagens 295 Gostos 0
Troféus totais: 25
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1 100 Posts

Não percebi bem...

Eu escrevo um post no meu blog e ele é enviado para o twitter?

Podes por exemplo , sempre que faças um post no teu blog... lançar o titulo e url do mesmo pro teu perfil do twitter...