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]
Again, the URL served exclusively as a sample purpose, I only want to hear about the feedback of the script itself, not the possiblity of who will use it at my website.
(1) Use cfmail + cfschedule, to send report every 2 or 3 hours to user, by email, FAX, SMS.
(2) If use database, it also can send updated report on desirable threshold, say by earnings, clicks, impression, channels, display locations (coupled with Tracking Scripts)
Noting some of your concerns, all above features will not Open Source. Let's keep going not arguing!
My apologies for not replying sooner. It's a shame you won't be open-sourcing the enhancements to the script but I can understand why.
Anyway, it's still an excellent script and judging by your screenshot you've now got some visual reports built in. However, I modifed how the output is displayed as follows to make the report easier to read than the original script:
Styles added to the head:
<style>
body {
text-align: center;
background-color: #fff;
color: #777;
font-family: verdana, arial, helvetica, sans-serif;
font-weight: normal;
font-size: 80%;
}
.topRow {
font-weight: bold;
background: #ccc;
color: #000;
}.bottomRow {
font-weight: bold;
background: #ccc;
color: #000;
}.evenRows {
background: #ddd;
}.oddRows {
background: #eee;
}.container {
width: 500px;
border: 1px solid black;
background: #fefefe;
}
</style>
And replaced:
<cfoutput><pre>#cfhttp.fileContent#</pre></cfoutput>
<cfset data = #cfhttp.fileContent#><!--- cleanup non-ascii characters --->
<cfset data = #REReplaceNoCase(data, "[^[:ascii:]]", "", "ALL")#><!--- determine number of rows --->
<cfset CountRows = 0>
<cfloop index="rows" list="#data#" delimiters="#chr(10)#">
<cfset CountRows = CountRows + 1>
</cfloop><!--- display as coloured table --->
<cfset CountVar = 0>
<div class="container">
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<cfloop index="rows" list="#data#" delimiters="#chr(10)#">
<cfif CountVar EQ 0>
<tr class="topRow">
<cfelseif CountVar EQ (CountRows -2)>
<tr class="bottomRow">
<cfelseif (CountVar MOD 2) EQ 0>
<tr class="evenRows">
<cfelse>
<tr class="oddRows">
</cfif>
<cfloop index="columns" list="#rows#" delimiters="#chr(09)#"><!--- cleanup line-feeds and other unnecessary characters --->
<cfset columns = #ReReplace(columns, "[^[:print:]]", "", "ALL")#>
<td><cfoutput>#columns#</cfoutput></td>
</cfloop>
</tr>
<cfif CountVar EQ (CountRows -2)>
<cfbreak>
</cfif>
<cfset CountVar = CountVar + 1>
</cfloop>
</table>
</div>
Now it displays as an HTML table with alternate coloured rows for easy reading.
I've also been wondering if there is a way to store the tracking code in a cookie to avoid re-logging in. This way you could update the report type in realtime with buttons to choose day, week, month etc...
I hope the development continues to go well! Thanks again.
Stretch
Thanks a lot for your reply, so far I'm using Javascript to Sort Table, not using database or cookie to store the report.
To All,
I feel gratitude of those of you telling me the security/privacy concerns, I just created a new page at http:\\MYwebsite/coldfusion/, for those of all either no or new to the software but want to have a try, because I do like you to try the script on your own website.
Tips of MYwebsite, per TOS of this forum, I cannot tell it directly, but you can find it out by
(1) my "user profile", or
(2) searching "Adsense Downloadable Report Auto Retriever" at Yahoo!(MUST with the quotation marks) or Google(no need quotation marks), AOL.
Thanks all, and have a great weekend!
Zhenghua
A Very Simple Example for sending Results to Your SMS (*) for Adsense Downloadable Report Auto Retriever v2.0a+
SMS: Short Message Service, function on a mobile phone that enables short messages to be relayed from one mobile phone to another, here we send it from our server to user's screen of mobile phone while requested, or triggered by settings, or periodically by settings.
Here I show you a way to send it to AT&T's ONLY.
....
<cfset strTimePeriod="thismonth"> <!--- you can change it, see the msg#12 of this thread --->
....
<cfset strReportlist = #REReplaceNoCase(cfhttp.fileContent, "[^[:ascii:]]", "", "ALL")#>
<cfset strReportlist=replace("#trim(strReportlist)#"," ","","ALL")>
<cfset strReportlist=replace(strReportlist,""," ","ALL")>
<cfset enl="#Chr(13)##Chr(10)#">
<cfset tmplistN=ListLen(strReportlist,#enl#)>
<cfset tmplistNa=tmplistN><!--- rows of the Report --->
<cfif #tmplistNa# LT 3>
<h3>No data or need more data.</h3>
<cfabort>
</cfif>
<cfset tmpLArray = ArrayNew(1)>
<cfloop INDEX="ListElement" LIST="#strReportlist#" DELIMITERS="#enl#">
<cfset tmpLArray[tmplistNa-tmplistN+1]=ListElement>
<cfset tmplistN=tmplistN-1>
</cfloop>
<cfset strThisMonthEarnings= #tmpLArray[tmplistNa]#>
....
<cfset strUserAgent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)">
<!--- change to your AT&T Digital PCS phone's telephoe number, formating as "555-555-5555" --->
<cfset strMyMobileNumber="555-555-5555">
<cfset strSMSFrom="Adsense">
<cfset strSMSSubject="#strThisMonthEarnings#">
<cfset strSMSmessage="#strLastRowofReport#">
<cfset digSize=len(strSMSSubject) + len(strSMSmessage) + 7> <!--- be sure to make it <=110 --->
<cfhttp
url = "http://www.mobile.att.net/messagecenter/pagersend.cgi"
method = "post"
userAgent = "#strUserAgent#"
>
<cfhttpparam type="FORMFIELD" name="pin" value="#strMyMobileNumber#">
<cfhttpparam type="FORMFIELD" name="from" value="#strSMSFrom#">
<cfhttpparam type="FORMFIELD" name="subject" value="#strSMSSubject#">
<cfhttpparam type="FORMFIELD" name="message" value="#strSMSmessage#">
<cfhttpparam type="FORMFIELD" name="sizebox" value="#digSize#">
<cfhttpparam type="FORMFIELD" name="submit" value="http://www.mobile.att.net/messagecenter/images/btn_sendmessage.gif">
</cfhttp>
1. Message text to AT&T Digital PCS phones is limited to 110 characters, any characters beyond 110 in the message text field will be truncated and not received by the phone.
2. To use this sample, the recipient must be any of AT&T compatible digital phone with text messaging service in the U.S. (Because this sample only for this service, we need to develop other scripts for different carriers, thus far over 150 SMS gateways around the world.)
Have fun!
Zhenghua
==============================
...
<!--- after the cfhttp--->
<cfset strReportlist=replace("#trim(cfhttp.fileContent)#"," ","{::}","ALL")>
<cfset strReportlist=replace(strReportlist," ","{:}","ALL")>
<cfset strReportlist=replace(strReportlist," ","-","ALL")>
<cfset enl="#Chr(13)##Chr(10)#">
<cfset tmplistN=ListLen(strReportlist,#enl#)>
<cfset tmplistNa=tmplistN><!--- rows of the results --->
<cfif #tmplistNa# LT 3>
<h3>No data or need more data.</h3>
<cfabort>
</cfif>
<cfset tmpLArray = ArrayNew(1)>
<cfloop INDEX="ListElement" LIST="#strReportlist#" DELIMITERS="#enl#">
<cfset tmpLArray[tmplistNa-tmplistN+1]=ListElement & "<br>">
<cfset tmpLArray[tmplistNa-tmplistN+1]=replace(tmpLArray[tmplistNa-tmplistN+1],
" ", "_","ALL")>
<cfset tmpLArray[tmplistNa-tmplistN+1] = #REReplaceNoCase(tmpLArray[tmplistNa-tmplistN+1], "[^[:print:]]", "{n}", "ALL")#>
<cfset tmpLArray[tmplistNa-tmplistN+1]=replace(tmpLArray[tmplistNa-tmplistN+1],"{n}{n}{n}"," ","ALL")>
<cfset tmpLArray[tmplistNa-tmplistN+1]=replace(tmpLArray[tmplistNa-tmplistN+1],"{n}","","ALL")>
<cfset tmplistN=tmplistN-1>
</cfloop>
<cfset strTodayRow=#replace(tmpLArray[tmplistNa-1],"<br>","","ALL")#>
<cfset strTotalRow=#replace(tmpLArray[tmplistNa],"<br>","","ALL")#>
========================================
#strTotalRow# could be insert to the Message body,
whether in SMS or <cfmail>'s body.
<code>From='#listlast(strTodayRow," ")# <#YourEmailAddress#>'
<real>From: $900.00 <YourEmail>
While using msn/hotmail account as #YourEmailAddress#, and
use MSN messenger service, you even no need to OPEN the email alter,
MSN will say "...$900.00 ...".
(Of course, you can use other Instant messenger services with Alter functions as well)
If you do use SMS, at your cellphone's screen it say:
FROM $900.00 ...
(you even don't need to click deep to read them...)
Cool?
=========================================
<cfset s=#listlast(strTodayRow," ")#>
<cfmail to ="YourEmailAddress" from ="#s# #TimeFormat(Now(),'h tt')# <YourEmailAddress>" subject="#s#" username = "YourUserNameatYourMailServer" password = "YourPasswordatYourMailServer" server = "YourMailServer" mailerid = "Adsense Downloadable Report Auto Retriever v2.0a+" timeout = "50">
#strTodayRow#
#strTotalRow#
</cfmail>
=========================================
Workable so far!
I also let it send me in every 3 hour...
ha-ha