Ver Mensaje Individual
  #5 (permalink)  
Antiguo 09/06/2011, 06:02
Avatar de abimaelrc
abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 15 años
Puntos: 1517
Respuesta: Crear url corta para enviar por email

Algo así
Código PHP:
Ver original
  1. <?php
  2. $url = 'http://to.ly/create.php';
  3. $body = 'url=http://forosdelweb.com';
  4. $c = curl_init($url);
  5. curl_setopt($c, CURLOPT_POST, true);
  6. curl_setopt($c, CURLOPT_POSTFIELDS, $body);
  7. curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
  8. $page = curl_exec($c);
  9.  
  10. $doc = @DOMDocument::loadHTML($page);
  11. $xpath = new DOMXPath($doc);
  12. echo $xpath->query('//div[@style="margin-top: 20px;"]/a')
  13.     ->item(0)
  14.     ->firstChild
  15.     ->nodeValue;
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos