Modificando Tweetme: sustituir bit.ly por microuri.com
| Categorías PHP, Programacion, Redes Sociales, Tecnologia, internet | Fecha 02-11-2009 | Comentario 1
Esta ha sido una rapidita pero exitosa modificacion para usar mi acortador MicroUri y no bit.ly en el plugin Tweetme de Wordpress.
Para hacer esto, solo hay que modificar una funcion llamada “tweetme_bitly_link”.
La funcion original se ve asi:
1 2 3 4 5 6 7 8 | function tweetme_bitly_link($id) {
if (function_exists('revcanonical_shorten') && $link = revcanonical_shorten($id)) {
return $link;
} else {
$link = get_permalink($id);
return file_get_contents('http://bit.ly/api?url=' . $link);
}
} |
La modificacion solo contiene tres lineas extras:
1 2 3 4 5 6 7 8 9 10 11 12 13 | function tweetme_bitly_link($id) {
if (function_exists('revcanonical_shorten') && $link = revcanonical_shorten($id)) {
return $link;
} else {
$link = get_permalink($id);
/**Williams Mendez **/
$ob = @simplexml_load_file('http://api.microuri.com/get.php?url='.$link);
if(is_object($ob) && isset($ob->Response) && strlen($ob->Response))
return $ob->Response;
return file_get_contents('http://bit.ly/api?url=' . $link);
}
} |