0

RSS ストリームに Google AdSense を追加しようとしています。「RSS 向け AdSense」はサードパーティに依存しているため、使用したくありません。

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 の使用をブロックして、ユーザーに RSS 向け AdSense サービスを強制していると思っていましたが、その後、Slashdot などのいくつかの人気のある Web サイトがまさに私がやりたいことを実行していることに気付きました。

確かに私は何か間違ったことをしていますが、指を置くことはできません。

編集:これは出力です

<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>
4

1 に答える 1

0

問題が発生している理由は、RSS フィード内にインラインまたは外部の JavaScript を含めることができないためです。

RSS 向け AdSense はサードパーティに依存している可能性がありますが、JavaScript を使用するのではなく、画像またはイメージ マップをフィードに含めることで機能します。

于 2009-08-19T12:37:52.807 に答える