Adsense Mobile Hack:有什么方法可以找出 PHP 脚本中最后回显的内容是什么?

发布于 2024-12-13 23:59:43 字数 701 浏览 2 评论 0原文

众所周知,我们不允许修改 Adsense PHP 脚本,因为这违反了 TOS。

我工作的网站之一是移动网站,针对设备类型“所有手机”创建的 Adsense 移动广告不会为某些设备提供“备用广告”选项奇怪的原因,但我超过 20% 的展示次数并未显示广告“(不匹配的广告请求)”。

没有 Adsense 支持,我在网上找不到任何解决此问题的方法。

但是,我注意到,当没有显示 Adsense for Mobile 广告时,Google 只会回显 。因此,要强制显示替代广告,我所需要做的就是找出 Google echo 的 的时间,然后自己显示替代广告。

现在,如果我可以更改以下行中的 Adsense PHP 代码,这将非常容易做到:

echo fread($google_ad_handle, 8192);

但同样,这将违反 TOS,我将面临被禁止的风险。

由于我正在执行此脚本的 include 操作,因此是否可以在 PHP 中确定脚本最后回显的内容是什么?

如果没有,那么您是否可以建议我使用其他替代方案来展示替代广告,这样我就不会浪费超过 20% 的展示次数?

As everyone knows, we are NOT allowed to modify the Adsense PHP script as it is a TOS violation.

One of the sites I work on is mobile, and the Adsense Mobile Ad creation for Device type "All Phones" does NOT give you the option for "Alternate ad" for some strange reason, yet over 20% of my impressions are NOT displaying an Ad "(Unmatched ad requests)".

There is no Adsense support, and I couldn't find any solution to this issue online.

However, I've noticed that when no Adsense for Mobile ad is displayed, Google just echo's <!-- google_afm -->. So all I need to do to force-display an Alternative Ad is to find out when Google echo's <!-- google_afm --> and then just display the alternate myself.

Now, this would be VERY easy to do if I could alter the Adsense PHP code in the following line:

echo fread($google_ad_handle, 8192);

But again, that would be a violation of the TOS and I would risk getting Banned.

Since I am doing an include of this script, is there anyway to determine in PHP what was the last thing echo'd by a script?

If not, then are there any other alternatives you can suggest for me to be able to display alternative ads so that I don't waste over 20% of my impressions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

囍孤女 2024-12-20 23:59:43
<?php

  ob_start();
  include "adsense_script.php";
  $output = ob_get_clean();
  if (substr($output,-19) == '<!-- google_afm -->') {
    // display alternate here
  }

?>
<?php

  ob_start();
  include "adsense_script.php";
  $output = ob_get_clean();
  if (substr($output,-19) == '<!-- google_afm -->') {
    // display alternate here
  }

?>
城歌 2024-12-20 23:59:43

您可以使用输出缓冲控制。例如:

ob_start();
include("/path/to/script.php");
$data = ob_get_contents();
ob_end_clean();

You can use output buffering control. For example:

ob_start();
include("/path/to/script.php");
$data = ob_get_contents();
ob_end_clean();
幽蝶幻影 2024-12-20 23:59:43

您可以使用输出缓冲,例如包含:

<?php
    /**
     * include_get_contents
     *
     * include a file and return it's output
     *
     * @param string $path filename of include
     * @return string
     */
    function include_get_contents($path)
    {
        ob_start();
        include($path);
        return ob_get_clean();
    }

You can use output buffering, like with the include:

<?php
    /**
     * include_get_contents
     *
     * include a file and return it's output
     *
     * @param string $path filename of include
     * @return string
     */
    function include_get_contents($path)
    {
        ob_start();
        include($path);
        return ob_get_clean();
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文