views:

262

answers:

1

The below function should be outputting a Vimeo thumbnail. Its not returning anything. I have tested for $id and it is passing into the function, and it is a valid vimeo ID for a video. When I replace the $out = xxx with $out = 'hello'; , nothing comes out. This leads me to believe no records are being returned in the xml call. Curl 7.12.1 is installed. What else could be a problem here?

function vimeo_thumbnail()
{
    global $TMPL, $DB, $SESS;

 $video_id  = $TMPL->fetch_param('id');

 if(!$video_id) {
  return;
 }

 // API endpoint
 $api_endpoint = 'http://www.vimeo.com/api/v2/video/'.$video_id.'.xml';

 // Curl helper function
 function curl_get($url) {
  $curl = curl_init($url);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_TIMEOUT, 30);
  $return = curl_exec($curl);
  curl_close($curl);
  return $return;
 }

 // Load the user info and clips
 $video_info = simplexml_load_string(curl_get($api_endpoint));

 foreach ($video_info->video as $video) {
  $out = '<img src="'.$video->thumbnail_medium.'" />';
 }

 $this->return_data .= $out;

}
A: 

to see the status of ur curl request use something like this in ur function

$return = curl_exec($curl);
$info = curl_getinfo($curl);
print_r($info);

this will tell u alot about the request and u will know what exactly is happening to ur request.. and u can continue to debug from there.

Sabeen Malik
Thanks Sab. Turns out I'm on a PHP4 server so simplexml_load_string wont' work.Can you possibly give me a replacement for this?
maybe this will help?http://www.webmaster-talk.com/php-forum/170192-problem-with-simplexml_load_string-and-php4.html
Sabeen Malik