facebook中的facebook链接

时间:2014-07-05 12:50:29

标签: php hyperlink rss

我正在尝试提取在Facebook RSS提要中生成的链接的PHP,并在点击后将其变为简单的html。链接看起来像这样:

http://l.facebook.com/l.php?u=http%3A%2F%2Fwww.theguardian.com%2Ftravel%2F2014%2Fapr%2F25%2Fitaly-puglia-salento-region&h=2AQF4oNrg&s=1

这是原始链接:

http://www.theguardian.com/travel/2014/apr/25/italy-puglia-salento-region

我正在使用此代码但似乎是第2行的错误。

$matches = array();
pregmatchall(/http:\/\/l\.facebook\.com\/l\.php\?u=([^"]+)/, $rss, $matches);

foreach($matches[0] as $index => $match) {
    $url = urldecode(html_entity_decode($matches[1][$index]));
    str_replace($match, $url, $rss);
}

1 个答案:

答案 0 :(得分:0)

试试这个

$matches = array();
$rss="http://l.facebook.com/l.php?u=http%3A%2F%2Fwww.theguardian.com%2Ftravel%2F2014%2Fapr%2F25%2Fitaly-puglia-salento-region&h=2AQF4oNrg&s=1";
preg_match_all('/http:\/\/l\.facebook\.com\/l\.php\?u=([^"]+)/', $rss, $matches);

foreach($matches[0] as $index => $match) {
    $url = urldecode(html_entity_decode($matches[1][$index]));
    str_replace($match, $url, $rss);
}

echo $url;