Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/10/2013, 11:09
Avatar de guardarmicorreo
guardarmicorreo
 
Fecha de Ingreso: noviembre-2012
Ubicación: Córdoba
Mensajes: 1.153
Antigüedad: 11 años, 6 meses
Puntos: 84
problema con la API de bitly (kevin marshal y robin monks)

Estoy trabajando con la API de bitly.

He descargado la API bitlyPHP.

En GitHub especifican los parámetros de la función para acortar la longURL

Cita:
4. Use any of the functions as such:

$results = bitly_v3_shorten('http://knowabout.it', 'j.mp');
Realizo exactamente lo que dice ahí y al ejecutar una prueba me devuelve lo siguiente

Cita:
Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in /var/www/vhosts/miservidor.com/httpdocs/models/bitly.php on line 1159 array(0) { }
La línea 1159 de la API está en la siguiente función, la marco con un comentario PHP

Código PHP:
Ver original
  1. /**
  2.  * Make a GET call to the bit.ly API.
  3.  *
  4.  * @param $uri
  5.  *   URI to call.
  6.  */
  7. function bitly_get_curl($uri) {
  8.   $output = "";
  9.   try {
  10.     $ch = curl_init($uri);
  11.     curl_setopt($ch, CURLOPT_HEADER, 0);
  12.     curl_setopt($ch, CURLOPT_TIMEOUT, 4);
  13.     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
  14.     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); //esta es la línea 1159
  15.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  16.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  17.     $output = curl_exec($ch);
  18.   } catch (Exception $e) {
  19.   }
  20.   return $output;
  21. }

La función shorten que llama a esta función es la siguiente

Código PHP:
Ver original
  1. function bitly_v3_shorten($longUrl, $domain = '', $x_login = '', $x_apiKey = '') {
  2.   $result = array();
  3.   $url = bitly_oauth_api . "shorten?access_token=" . bitlyKey . "&longUrl=" . urlencode($longUrl);
  4.   if ($domain != '') {
  5.     $url .= "&domain=" . $domain;
  6.   }
  7.   if ($x_login != '' && $x_apiKey != '') {
  8.     $url .= "&x_login=" . $x_login . "&x_apiKey=" . $x_apiKey;
  9.   }
  10.   $output = json_decode(bitly_get_curl($url)); //aquí llama a la función donde genera el problema
  11.   if (isset($output->{'data'}->{'hash'})) {
  12.     $result['url'] = $output->{'data'}->{'url'};
  13.     $result['hash'] = $output->{'data'}->{'hash'};
  14.     $result['global_hash'] = $output->{'data'}->{'global_hash'};
  15.     $result['long_url'] = $output->{'data'}->{'long_url'};
  16.     $result['new_hash'] = $output->{'data'}->{'new_hash'};
  17.   }
  18.   return $result;
  19. }

¿A qué se puede deber este error? ¿es un problema de configuración del servidor, de configuración en tiempo de ejecución o de pasar unos parámetros erróneos?

La última posibilidad puede ser posible, ya que los parámetros que hay que pasar exactamente no los explica bien bitly ni los autores de las funciones.
__________________
Ayúdame a hacerlo por mi mismo.