Hello, I wrote the class Link which has a method shortTolong() this should return the real URL for a shortend url by returning the 'location' response header. i tested it and it works OK here is the code
public function shortTolong()
{
$urlMatch = array();
$ch = curl_init();
$options = array
(
CURLOPT_URL=>$this->getUrl(),
CURLOPT_HEADER=>true,
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_FOLLOWLOCATION=>false,
CURLOPT_NOBODY=>true);
curl_setopt_array($ch, $options);
$server_output = curl_exec($ch);
preg_match_all(LINK, $server_output,&$urlMatch,PREG_SET_ORDER);
if($urlMatch)
{
foreach($urlMatch as $set)
{
$extracted_url = $set[2].'://'.$set[3];
}
return $extracted_url;
}
else
{
return $this->getUrl();
}
}
the problem starts when i try to use this method on other file which uses FeedParser to get feed entries that contain this short urls i ned to analize from some reason i get as a result the shorl url instaed of the long one here is the code:
foreach($parser->getItems() as $item)
{
$idpreg = '/\d+/';
preg_match_all($idpreg, $item['ID'],$statusid);
$retweetid = ($statusid[0][1]);
$datetime = $item['PUBLISHED'];
$user = $item['AUTHOR']['NAME'];
preg_match_all(LINK, $item['TITLE'], &$linkMatch);
$final = $linkMatch[0][0];
//if($linkMatch[0][0])
echo '<p>';
$link = new Link($final);
echo $link->getUrl();
echo '<br>';
echo $link->shortTolong();
echo '<br>';
echo $user;
echo '<br>';
echo $retweetid;
echo '</p>';
}
from some reason i get the same result for getUrl() and shortTolong() and i know for certain this is an error.
any ideas why this is happening? Thanks
Edit- I added an error notice to the method with curl_eror i get this error massage: "Protocol http not supported or disabled in libcurl" as i said i tested this method from the and it's working fine as as stand alone in the same envoirment (no changes) i suspect it has somthing to do with FeedParser using curl too....