【问题标题】:AdSense in RSS Stream - PHPRSS 流中的 AdSense - PHP
【发布时间】:2009-08-19 20:37:52
【问题描述】:

我正在尝试在 RSS 流中添加一些 Google AdSense。我不想使用他们的“AdSense for RSS”,因为它依赖于第三方。

我注意到在 RSS 中,您不能使用小于/大于字符,因为它会破坏 RSS 代码。好吧,我使用 htmlentities() 函数来逃避这些。在流中显示基本 HTTP 效果很好,如下所示:

$bottom = '<p><a href="http://www.domain.com/image-' .$row['id']. '.html" target="_blank">Post a comment ></a>';
echo htmlentities($bottom);

但是,当我尝试对 Google AdSense 代码执行完全相同的操作时,没有任何显示。

$ad_code = '<script type="text/javascript"><!--
                    google_ad_client = "pub-37909010735xxxx";
                    /* banner, RSS Feed */
                    google_ad_slot = "xxxxx";
                    google_ad_width = 468;
                    google_ad_height = 60;
                    //-->
                    </script>
                    <script type="text/javascript"
                    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                    </script>';
echo htmlentities($ad_code);

起初我以为 Google 阻止了 AdSense 的使用,以迫使用户使用 AdSense for RSS 服务,但后来我注意到一些流行的网站,例如 Slashdot,正是我想做的事情。

我肯定做错了什么,但我不能指手画脚。

编辑:这是输出

<description>&lt;a href=&quot;http://www.domain.com/image-8551.html&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://www.domain.com/images/1250670754.jpg&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I guess being called snuggly-bumpkins was too much?&lt;script type=&quot;text/javascript&quot;&gt;&lt;!--
                    google_ad_client = &quot;pub-3790901073xxxxx&quot;;
                    /* banner, RSS Feed */
                    google_ad_slot = &quot;xxxxxxx&quot;;
                    google_ad_width = 468;
                    google_ad_height = 60;
                    //--&gt;

                    &lt;/script&gt;
                    &lt;script type=&quot;text/javascript&quot;
                    src=&quot;http://pagead2.googlesyndication.com/pagead/show_ads.js&quot;&gt;
                    &lt;/script&gt;&lt;p&gt;&lt;a href=&quot;http://www.domain.com/image-8551.html&quot; target=&quot;_blank&quot;&gt;Post a comment &gt;&lt;/a&gt;</description>

【问题讨论】:

    标签: php adsense


    【解决方案1】:

    您遇到问题的原因是您无法在 RSS 提要中包含内联或外部 JavaScript。

    AdSense for RSS 可能依赖于第三方,但它通过将图像或图像映射添加到供稿中而不是使用 JavaScript 来工作。

    【讨论】:

      猜你喜欢
      • 2012-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多