如何为自己的广告网络使用Javascript和PHP生成广告块 [英] How do I generate Ad blocks with Javascript and PHP for my own Ad Network

查看:97
本文介绍了如何为自己的广告网络使用Javascript和PHP生成广告块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要像google adsense一样自己创建一个广告服务器。但我需要知道很少的事情来规划我的项目。我用谷歌搜索了很多方面,但是我找不到清楚解释我需要知道的事情。我在Stackoverflow中搜索,但结果并没有解释我。因此,不要误解为重复,不要误解我,因为我可能没有多少研究(因为我在发布之前尝试过)。

I'm going to create an adserver by myself like google adsense. But I need to know few things to plan my project. I searched in many ways with google but I couldn't find clearly explained things that I need to know. I search in Stackoverflow but the results didn't explained me a much. So don't misunderstand this as a duplicate and don't misunderstand about me as I may not researched much(Because I tried it before post this).

这是一个示例Google广告代码

This is a sample google ad code

<– Begin Google Adsense code –>
<script type="text/javascript">
google_ad_client = "ad-client-code-goes-here";
google_ad_slot = "ad-slot-code-goes-here";
google_ad_width = 300;
google_ad_height = 250;
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<– End Google Adsense code –>




  1. 如何生成上述广告代码,例如google做什么? (我的意思是只需要实现简单的javascript代码)

  1. How do I generate ad codes like above, like google do ? (I mean just simple javascript codes to implement)

当用户使用上述代码时,如何使用javascript投放广告?

How do I use javascript to serve ads when users use codes like above ?

如何在这种情况下使用javascript连接php?
我的意思是上面代码的来源只是show_ads.js一个javascript文件。但我必须使用php投放广告。
(因为我不认为java会从数据库中获取广告详细信息并创建广告内容并在不使用php的情况下发送。)
那么我该如何处理呢?

How do I connect php with javascript on this scenario ? I mean the source of the above code is just show_ads.js a javascript file. But I have to serve ads using php. (Because I don't think java will get ad details from database and create the ad content and send it without using php.) So how do I deal with that ?

(如果有人能提供简单的javascript和php代码来解释这个案例,我会很感激。因为我需要知道这些事情是如何用代码完成的在php和javascript)

(If anyone can provide simple javascript and php codes to explain this case I would be thankful. Because I need to know how these things done with codes in php and javascript)

推荐答案

首先 - 创建一个php文件,您可以在其中生成基于广告的输出在google_ad_client上,google_ad_slot,google_ad_width,google_ad_height(例如showads.php)
秒 - 通过js调用php文件。

First - Create a php file where you can generate advertise output based on google_ad_client, google_ad_slot, google_ad_width, google_ad_height (ex. showads.php) Second - call the php file through js.

js文件示例:

document.write('<iframe src="http://google.com/showads.php?google_ad_client='+ google_ad_client+'&google_ad_slot='+google_ad_slot+' margin=0 frameborder=0 scrolling=no allowtransparency=true ></iframe>');

这是一个简单的例子e。

this is a simple example.

但如果你想创建像google adsense这样的东西我会建议雇用人。

but i will suggest to hire people if you want to create something like google adsense.

这篇关于如何为自己的广告网络使用Javascript和PHP生成广告块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆