【问题标题】:facebook links in RSSRSS 中的 Facebook 链接
【发布时间】:2014-07-05 12:50:28
【问题描述】:

我正在尝试提取在 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);
}

【问题讨论】:

  • 这个看似错误是否带有相关的错误消息?
  • 你有语法错误pregmatchall => preg_match_all
  • @Vijayaragavendran 尝试了下划线,但仍然给出错误:PHP Syntax Check: Parse error: syntax error, unexpected '/', expecting ')' in your code on line 2. 我检查了代码phpcodechecker.com
  • 为什么不改用parse_url,你的目标只是获得?u=的价值
  • 试试这个preg_match_all('/http:\/\/l\.facebook\.com\/l\.php\?u=([^"]+)/', $rss, $matches);

标签: php hyperlink rss


【解决方案1】:

试试这个

$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;

【讨论】:

  • 试过这个,但一旦点击 php 再次出现,它也适用于那个特定的链接
  • 那你必须重写预赛
  • 不知道该怎么做。无论如何,如果我将输出悬停,我可以看到 php 再次出现
  • 这是 dom _onclick="LinkshimAsyncLink.swap(this, " http:\="" \="" l.facebook.com\="" l.php? u=etc等
猜你喜欢
  • 2014-08-25
  • 2017-11-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-27
  • 2014-02-17
  • 2023-03-31
相关资源
最近更新 更多