さて、どうしましょうか。

ニュース&沖縄生活ブログ。
垂れ流されるニュースを聞いて思ったことや、沖縄生活での日常などを徒然に。




携帯用Googleアドセンスのテスト
携帯用アドセンスのテスト
PHP
$value) { if ($param == 'client') { google_append_url($google_ad_url, $param, 'ca-mb-' . $GLOBALS['google'][$param]); } else if (strpos($param, 'color_') === 0) { google_append_color($google_ad_url, $param); } else if ((strpos($param, 'host') === 0) || (strpos($param, 'url') === 0)) { google_append_url($google_ad_url, $param, $google_scheme . $GLOBALS['google'][$param]); } else { google_append_globals($google_ad_url, $param); } } google_append_url($google_ad_url, 'dt', round(1000 * array_sum(explode(' ', microtime())))); return $google_ad_url;}$google_ad_handle = @fopen(google_get_ad_url(), 'r');if ($google_ad_handle) { while (!feof($google_ad_handle)) { echo fread($google_ad_handle, 8192); } fclose($google_ad_handle);}?>


CGI/Perl
#!/usr/bin/perluse LWP::UserAgent;use Time::HiRes qw(gettimeofday);use URI::Escape;sub google_append_color { my @color_array = split(/,/, $_[0]); return $color_array[$_[1] % @color_array];}sub google_append_screen_res { my $screen_res = $ENV{"HTTP_UA_PIXELS"}; my $delimiter = "x"; if ($screen_res == "") { $screen_res = $ENV{"HTTP_X_UP_DEVCAP_SCREENPIXELS"}; $delimiter = ","; } my @res_array = split($delimiter, $screen_res); if (@res_array == 2) { return "&u_w=" . $res_array[0] . "&u_h=" . $res_array[1]; }}sub google_append_dcmguid { my $dcmguid = $ENV{"HTTP_X_DCMGUID"}; if ($dcmguid) { return "&dcmguid=" . $dcmguid; }}my $google_dt = sprintf("%.0f", 1000 * gettimeofday());my $google_scheme = ($ENV{"HTTPS"} eq "on") ? "https://" : "http://";my $google_host = uri_escape($google_scheme . $ENV{"HTTP_HOST"});my $google_ad_url = "http://pagead2.googlesyndication.com/pagead/ads?" . "ad_type=text_image" . "&channel=9029098636" . "&client=ca-mb-pub-6309652373751307" . "&dt=" . $google_dt . "&format=mobile_double" . "&host=" . $google_host . "&ip=" . uri_escape($ENV{"REMOTE_ADDR"}) . "&markup=xhtml" . "&oe=utf8" . "&output=xhtml" . "&ref=" . uri_escape($ENV{"HTTP_REFERER"}) . "&url=" . $google_host . uri_escape($ENV{"REQUEST_URI"}) . "&useragent=" . uri_escape($ENV{"HTTP_USER_AGENT"}) . google_append_screen_res() . google_append_dcmguid();my $google_ua = LWP::UserAgent->new;my $google_ad_output = $google_ua->get($google_ad_url);if ($google_ad_output->is_success) { print $google_ad_output->content;}


JSP
<%@ page import="java.io.BufferedReader, java.io.InputStreamReader, java.io.IOException, java.io.UnsupportedEncodingException, java.net.URL, java.net.URLEncoder" %><%!private static final String PAGEAD = "http://pagead2.googlesyndication.com/pagead/ads?";private void googleAppendUrl(StringBuilder url, String param, String value) throws UnsupportedEncodingException { if (value != null) { String encodedValue = URLEncoder.encode(value, "UTF-8"); url.append("&").append(param).append("=").append(encodedValue); }}private void googleAppendColor(StringBuilder url, String param, String value, long random) { String[] colorArray = value.split(","); url.append("&").append(param).append("=").append( colorArray[(int)(random % colorArray.length)]);}private void googleAppendScreenRes(StringBuilder url, String uaPixels, String xUpDevcapScreenpixels) { String screenRes = uaPixels; String delimiter = "x"; if (uaPixels == null) { screenRes = xUpDevcapScreenpixels; delimiter = ","; } if (screenRes != null) { String[] resArray = screenRes.split(delimiter); if (resArray.length == 2) { url.append("&u_w=").append(resArray[0]); url.append("&u_h=").append(resArray[1]); } }}private void googleAppendDcmguid(StringBuilder url, String dcmguid) { if (dcmguid != null) { url.append("&dcmguid=").append(dcmguid); }}%><%long googleDt = System.currentTimeMillis();String googleHost = (request.isSecure() ? "https://" : "http://") + request.getHeader("Host");StringBuilder googleAdUrlStr = new StringBuilder(PAGEAD);googleAdUrlStr.append("ad_type=text_image");googleAdUrlStr.append("&channel=9029098636");googleAdUrlStr.append("&client=ca-mb-pub-6309652373751307");googleAdUrlStr.append("&dt=").append(googleDt);googleAdUrlStr.append("&format=mobile_double");googleAppendUrl(googleAdUrlStr, "host", googleHost);googleAppendUrl(googleAdUrlStr, "ip", request.getRemoteAddr());googleAdUrlStr.append("&markup=xhtml");googleAdUrlStr.append("&oe=utf8");googleAdUrlStr.append("&output=xhtml");googleAppendUrl(googleAdUrlStr, "ref", request.getHeader("Referer"));String googleUrl = request.getRequestURL().toString();if (request.getQueryString() != null) { googleUrl += "?" + request.getQueryString().toString();}googleAppendUrl(googleAdUrlStr, "url", googleUrl);googleAppendUrl(googleAdUrlStr, "useragent", request.getHeader("User-Agent"));googleAppendScreenRes(googleAdUrlStr, request.getHeader("UA-pixels"), request.getHeader("x-up-devcap-screenpixels"));googleAppendDcmguid(googleAdUrlStr, request.getHeader("X-DCMGUID"));try { URL googleAdUrl = new URL(googleAdUrlStr.toString()); BufferedReader reader = new BufferedReader( new InputStreamReader(googleAdUrl.openStream(), "UTF-8")); for (String line; (line = reader.readLine()) != null;) { out.println(line); }} catch (IOException e) {}%>


ASP
<%Function googleColor(value, random) Dim colorArray colorArray = Split(value, ",") googleColor = colorArray(random Mod (UBound(colorArray) + 1))End FunctionFunction googleScreenRes() Dim screenRes, delimiter, resArray screenRes = Request.ServerVariables("HTTP_UA_PIXELS") delimiter = "x" If IsEmpty(screenRes) Then screenRes = Request.ServerVariables("HTTP_X_UP_DEVCAP_SCREENPIXELS") delimiter = "," End If resArray = Split(screenRes, delimiter, 2) If (UBound(resArray) + 1) = 2 Then googleScreenRes = "&u_w=" & resArray(0) & "&u_h=" & resArray(1) End IfEnd FunctionFunction googleDcmguid() Dim dcmguid dcmguid = Request.ServerVariables("HTTP_X_DCMGUID") If Not IsEmpty(dcmguid) Then googleDcmguid = "&dcmguid=" & dcmguid End IfEnd FunctionDim googleTime, googleDt, googleScheme, googleHostgoogleTime = DateDiff("s", "01/01/1970 00:00:00", Now())googleDt = (1000 * googleTime) + Round(1000 * (Timer - Int(Timer)))googleScheme = "http://"If StrComp(Request.ServerVariables("HTTPS"), "on") = 0 Then googleScheme = "https://"googleHost = Server.URLEncode(googleScheme & Request.ServerVariables("HTTP_HOST"))Dim googleAdUrl, googleAdOutputgoogleAdUrl = "http://pagead2.googlesyndication.com/pagead/ads?" &_ "ad_type=text_image" &_ "&channel=9029098636" &_ "&client=ca-mb-pub-6309652373751307" &_ "&dt=" & googleDt &_ "&format=mobile_double" &_ "&host=" & googleHost &_ "&ip=" & Server.URLEncode(Request.ServerVariables("REMOTE_ADDR")) &_ "&markup=xhtml" &_ "&oe=utf8" &_ "&output=xhtml" &_ "&ref=" & Server.URLEncode(Request.ServerVariables("HTTP_REFERER")) &_ "&url=" & googleHost & Server.URLEncode(Request.ServerVariables("URL")) &_ "&useragent=" & Server.URLEncode(Request.ServerVariables("HTTP_USER_AGENT")) &_ googleScreenRes() &_ googleDcmguid()Set googleAdOutput = Server.CreateObject("MSXML2.ServerXMLHTTP")googleAdOutput.Open "GET", googleAdUrl, falsegoogleAdOutput.SendResponse.Write(googleAdOutput.responseText)%>



ちなみに。

PC用のGoogleアドセンス。
さきほどまでは表示がおかしかったのでつが、
早くも、いい感じで表示されてきました(^^)
| 鳥頭 | 資産運用 | 23:58 | comments(2) | trackbacks(0) |
ダメか。。。。

楽天のアフィリエイトなんかだと、
PC,携帯 共通のコードで表示されるんですけどね〜。

配信広告だから、ちょっといろいろと設定などが必要なようでつね。。。
| G | 2009/02/05 12:01 AM |
追記。

ほんとは
こちら
http://bonbon-voyage.net/category/mobile/index.html
に載せたいのですが。。。。
| G | 2009/02/05 12:02 AM |









http://blog.bonbon-voyage.net/trackback/880170
 123456
78910111213
14151617181920
21222324252627
28293031   
<< October 2018 >>
+ SELECTED ENTRIES
+ CATEGORIES
+ ARCHIVES
+ LINKS
[プレスブログ]価値あるブログに掲載料をお支払いします。 にほんブログ村 健康ブログ セルフケアへ

+ PROFILE