Forum Moderators: martinibuster
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GAS Report</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<!--- Input username below --->
<cfset strYourEmailAddress="YOUEmailAddress">
<!--- Input password below --->
<cfset strYourPassword="YourPassWord">
<cfset strTimePeriod="thismonth">
<!--- Select one or input one you want to retrieve (by URL.strTimePeriod or Form.strTimePeriod)
<cfset strTimePeriod="alltime">
<cfset strTimePeriod="today">
<cfset strTimePeriod="yesterday">
<cfset strTimePeriod="last7days">
<cfset strTimePeriod="lastmonth">
--->
<cfset strGasURLstart="https://www.google.com/adsense/reports-aggregate?timeperiod=simple&timeperiod.simpletimeperiod=">
<cfset strGasURLend="&reportType=property&groupByPref=date&null=Display+Report&csv=true">
<!--- The URL to be retrieved --->
<cfset strGasURL= strGasURLstart & strTimePeriod & strGasURLend>
<!--- Your userAgent --->
<cfset strUserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)">
<cfhttp
url = "https://www.google.com/adsense/login.do"
method = "post"
userAgent = "#strUserAgent#"
>
<cfhttpparam type="FORMFIELD" name="destination" value="">
<cfhttpparam type="FORMFIELD" name="username" value="#strYourEmailAddress#">
<cfhttpparam type="FORMFIELD" name="password" value="#strYourPassword#">
<cfhttpparam type="FORMFIELD" name="null" value="Login">
</cfhttp>
<cfset pos1=find("?s=","#cfhttp.fileContent#",1)>
<cfif pos1>
<cfset pos2=find("&","#cfhttp.fileContent#",pos1)>
<cfset strS=mid("#cfhttp.fileContent#",pos1+3,pos2-pos1-3)>
<cfif len(strS) EQ 11> <!--- the URL session "s" of GAS, I guess --->
<cfoutput>#strS#</cfoutput>
<cfset strGasURL= strGasURLstart & strTimePeriod & strGasURLend & "&s=#strS#">
<cfhttp url = "#strGasURL#" method = "get" userAgent = "#strUserAgent#" name = "qryGASreport"> </cfhttp>
<cfif isdefined("qryGASreport")>
<cfoutput>
<cfdump var="#qryGASreport#">
</cfoutput>
</cfif>
</cfif>
</cfif>
</body>
</html>
=============================
Feedback welcome!
[edited by: zhenghua at 2:21 pm (utc) on Mar. 19, 2004]
Nice idea. Unfortunately I get an error:
Invalid CFML construct found on line 51 at column 12.
ColdFusion was looking at the following text:
=The CFML compiler was processing:
a cfhttpurl tag beginning on line 51, column 2.
a cfhttpurl tag beginning on line 51, column 2.
a cfhttpurl tag beginning on line 51, column 2.
The error occurred in D:\root\pub\ads.cfm: line 51
49 : <cfoutput>#strS#</cfoutput>
50 : <cfset strGasURL= strGasURLstart & strTimePeriod & strGasURLend & "&s=#strS#">
51 : <cfhttpurl = "#strGasURL#" method = "get" userAgent = "#strUserAgent#" name = "qryGASreport"> </cfhttp>
52 : <cfif isdefined("qryGASreport")>
53 : <cfoutput>
Not sure I understand your second post. Are you looking for ideas to get this working or does it work for you already?
1) It works on my CFMX6.1 server,
2) I think maybe you can debug after Line 49 : <cfoutput>#strS#</cfoutput> .
<!---
<cfset strGasURL= strGasURLstart & strTimePeriod & strGasURLend & "&s=#strS#">
<cfhttpurl = "#strGasURL#" method = "get" userAgent = "#strUserAgent#" name = "qryGASreport"> </cfhttp>
<cfif isdefined("qryGASreport")>
<cfoutput>
<cfdump var="#qryGASreport#">
</cfoutput>
--->
Just to see if the fist CFHTTP got the value of "s". If Not, maybe there is a network problem, in fact, the length of "s" is 11.
Line 51 should read like this
<cfhttp url = "#strGasURL#" method = "get" userAgent = "#strUserAgent#" name = "qryGASreport"> </cfhttp>
note the space AFTER <cfhttp and BEFORE the url =
I'm at the moment not behind my PC/Server so I can not test it!
Noel
tKQ_LX4AqS9
Date Page impressions Clicks Clickthrough rate Your earnings
3/1/2004 17070 809 4.74% $412.59
3/2/2004 17009 506 2.97% $227.70
3/3/2004 20107 503 2.50% $352.10
3/4/2004 20404 608 2.98% $729.60
3/5/2004 20104 502 2.50% $160.64
3/6/2004 10206 601 5.89% $264.44
3/7/2004 13004 450 3.46% $247.50
3/8/2004 10409 801 7.70% $312.39
3/9/2004 10500 902 8.59% $405.90
3/10/2004 10906 689 6.32% $509.86
3/11/2004 20503 547 2.67% $224.27
3/12/2004 10201 214 2.10% $186.18
3/13/2004 10407 200 1.92% $112.00
3/14/2004 40908 1678 4.10% $369.16
3/15/2004 20307 698 3.44% $328.06
3/16/2004 30605 914 2.99% $594.10
3/17/2004 20306 1056 5.20% $686.40
3/18/2004 40356 2047 5.07% $921.15
3/19/2004 401 20 4.99% $17.80Totals 343713 13745 4.2% $7061.84
I'm now not getting an error, but I'm only getting the 11 character tracking code.
If I remove the <cfif isdefined("qryGASreport")> and just dump qryGASreport it always returns an undefined error.
I'm going to keep playing - this is a great idea so hopefully I'll get it working.
Try this, if you cannot cfdump.
<cfhttp url="#strGasURL#" method="get" userAgent="#strUserAgent#" name="ryGASreport"></cfhttp>
<cfoutput><pre>#cfhttp.fileContent#</pre></cfoutput>
<cfoutput><pre>#cfhttp.fileContent#</pre></cfoutput> works :-)
"qryGASreport" is a query, cfdump can display it, if you're using CFMX 6.1
This is a great piece of code and I'd be interested to see what else you manage to do with it.
Thanks again.
Stretch
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AdSense Downloadable Report Auto Retriever (V1.0.2b)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.styf1 {
font-size: 12px;
color: 666666;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>
</head>
<body>
<!--- Input username below --->
<cfset strYourEmailAddress="REPLACE WITH YOUR EMAIL ADDRESS">
<!--- Input password below --->
<cfset strYourPassword="REPLACE WITH YOUR Password">
<!---
Select one or input one you want to retrieve (by URL.strTimePeriod or Form.strTimePeriod)
<cfset strTimePeriod="alltime">
<cfset strTimePeriod="today">
<cfset strTimePeriod="yesterday">
<cfset strTimePeriod="last7days">
<cfset strTimePeriod="lastmonth">
---><cfset strTimePeriod="thismonth">
<cfset strGasURLstart="https://www.google.com/adsense/reports-aggregate?timeperiod=simple&timeperiod.simpletimeperiod=">
<cfset strGasURLend="&reportType=property&groupByPref=date&null=Display+Report&csv=true">
<!--- The URL to be retrieved --->
<cfset strGasURL= strGasURLstart & strTimePeriod & strGasURLend>
<!--- Your userAgent --->
<cfset strUserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)">
<cfhttp
url = "https://www.google.com/adsense/login.do"
method = "post"
userAgent = "#strUserAgent#"
>
<cfhttpparam type="FORMFIELD" name="destination" value="">
<cfhttpparam type="FORMFIELD" name="username" value="#strYourEmailAddress#">
<cfhttpparam type="FORMFIELD" name="password" value="#strYourPassword#">
<cfhttpparam type="FORMFIELD" name="null" value="Login">
</cfhttp>
<cfset pos1=find("?s=","#cfhttp.fileContent#",1)>
<cfif pos1>
<cfset pos2=find("&","#cfhttp.fileContent#",pos1)>
<cfset strS=mid("#cfhttp.fileContent#",pos1+3,pos2-pos1-3)>
<cfif len(strS) EQ 11><cfset strGasURL= strGasURLstart & strTimePeriod & strGasURLend & "&s=#strS#">
<cfoutput>URL:#strGasURL#</cfoutput>
<cfhttp url="#strGasURL#" method="get" userAgent="#strUserAgent#" name="ryGASreport"></cfhttp>
<cfoutput><pre>#cfhttp.fileContent#</pre></cfoutput>
<cfelse>
No data available. Try at least 1 hour Later....
</cfif>
<cfelse>
No data available. Try at least 1 hour Later....
</cfif><p>Updated Mar 19, 2004<strong> V1.0.2b</strong><br/>
<br/>
<span class="styf1">Google<sup>TM</sup> is a trademark of Google Inc. Google AdSense is for web publishers who want to make more revenue from advertising on their site while maintaining editorial quality. AdSense delivers text-based Google AdWords ads that are relevant to what your readers see on your pages and Google pays you. <a href="https://www.google.com/adsense/faq#start1" target="_blank">What is Google AdSense? </a></span> </p>
</body>
</html>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>AdSense Downloadable Report Auto Retriever (V1.0.2b)</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
.styf1 {
font-size: 12px;
color: #666;
font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>
</head>
<body>
<%
'Input username below
strYourEmailAddress="REPLACE WITH YOUR EMAIL ADDRESS"
'Input password below
strYourPassword="REPLACE WITH YOUR Password"'Select one or input one you want to retrieve (by URL.strTimePeriod or Form.strTimePeriod)
' strTimePeriod = "alltime"
' strTimePeriod = "today"
' strTimePeriod = "yesterday"
' strTimePeriod = "last7days"
' strTimePeriod = "lastmonth"
strTimePeriod = "thismonth"
strGasURLstart = "https://www.google.com/adsense/reports-aggregate?timeperiod=simple&timeperiod.simpletimeperiod="
strGasURLend = "&reportType=property&groupByPref=date&null=Display+Report&csv=true"
'The URL to be retrieved
strGasURL = strGasURLstart & strTimePeriod & strGasURLend
'Your userAgent
strUserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"
%>
<form action="https://www.google.com/adsense/login.do" method="post" userAgent="<%= strUserAgent %>">
<input type="hidden" name="destination" value="">
<input type="hidden" name="username" value="<%= strYourEmailAddress %>">
<input type="hidden" name="password" value="<%= strYourPassword %>">
<input type="hidden" name="null" value="Login">
</form>
<%
pos1 = instr(cfhttp.fileContent,"?s=",1)
if pos1 then
pos2 = instr(cfhttp.fileContent,"&",pos1)
strS = mid(cfhttp.fileContent,(pos1+3),(pos2-pos1-3))
if len(strS) = 11 then
strGasURL = strGasURLstart & strTimePeriod & strGasURLend & "&s=" & strS
response.write "URL:" & strGasURL
%>
<form action="<%= strGasURL %>" method="get" userAgent="<%= strUserAgent %>" name="<%= ryGASreport %>" />
<%
response.write "<pre>" & cfhttp.fileContent & "</pre>"
else
response.write "No data available. Try at least 1 hour Later...".
end if
else
response.write "No data available. Try at least 1 hour Later...."
end if
%>
<p>Updated Mar 19, 2004<strong> V1.0.2b.asp</strong><br/>
<br/>
<span class="styf1">Google<sup>TM</sup> is a trademark of Google Inc.
Google AdSense is for web publishers who want to make more revenue from
advertising on their site while maintaining editorial quality. AdSense
delivers text-based Google AdWords ads that are relevant to what your
readers see on your pages and Google pays you.
<a href="https://www.google.com/adsense/faq#start1" target="_blank">What
is Google AdSense?</a></span></p>
</body>
</html>
</body>
</html>
I know some of you worry about it, but as my website is 6-year-old, I'm sure in fact I don't want to steal other guys' information, just to show how to use diagram without database. The bottom line is you can always change password after you've tried that. In addition, if you know what kinda business I am doing, you have to trust me, ha-ha.
Have fun!
See, I know some of them don't trust others, that's okay, and my business solely based on trust, I completely understand their concerns.
Since I'm not going to sell it or persuade others to try it, I feel comfortable and willing to agree to disagree, where each side acknowledges that the
others has different points of view and that's the law of natural.
I'm going to continue my work and don't have time to waste on resolving impossible arguments.
Thanks,
Zhenghua
you have to trust me, ha-ha.
As a serious businessman, I promise not to steal/peek/collect/store your information.
OK zhenghua, enough is enough.
Adsense publishers can check their stats easily when they login to their account: [google.com...]
So, why do we need your "service"?
Why are you encouraging Adsense publishers to reveal their Adsense username/password on your site?
In fact, at marketplace there are at least 10 or more services for Adsense Report analysis, most of them are free.
I never say you NEED to try mine or others, you can always use your own analysis scripts/tools at your own website(s), you can also log in [google.com...]
My purpose is only open source a possible way to use the report, not persuade others to try this at my own website, as I mentioned before, I do care about the traffic expense.
I never lobby anyone to try this, my only intention is to show kindness to you all, especially who interested in this scripts, to show them how to use Coldfusion to download this report and make it a more human-readable diagram.
Thanks for your time,
Zhenghua
1) I posted a cfml script to show how to download the report.
2) Stretch replied me to discuss a bug;
3) Noel corrected the problem;
4) Stretch worked well about this script;
5) I said I could make some improvement, then told the location ...
6) Noel said people may not want to try it at my website;
7) In fact, I just show it to Stretch, because he/she encouraged me to do more, and I did it;
8) Stretch did not reply me, but some replied with same theme "we don't want to try".
9) The thing is I do NOT want you to try.