Friday, January 29, 2010

Sending Encrypted Data via URL?

Another lesson learned.

I am working on my PayPal Adaptive Payments application and I want buyers to be able to report when books are received or not received. Being the clever type of guy I am, I decided I should encrypt the data being sent in the email like the pay key that PayPal sends when first creating a sale through the AP. It is only good for a few hours after it is created for finishing the transaction but it is a great number for tracking payments. But I don't want it getting out to just anybody.

I tried doing a straight encryption but that ends up with all sorts of garbage that is not URL compatible. Being the genius guru I am, I figured I would just urlencode it to fix that problem.

Didn't work.

Turns out that it is pretty much impossible to reverse this process. Ends up with some garbage coming out. Oh well.

Just for everyones' enjoyment, the site I'm working on is at http://www.donomall.com. You can get to the book section from there. Anybody wanting to comment on the sites can do so. I have thick skin. Usually. I am NOT a designer. Keep that in mind. :)

Labels: , , ,

Tuesday, January 26, 2010

Unexpected Action from ColdFusion Tag

Don't you hate it when things don't work the way you think they should? Especially when you check and recheck trying to find a problem only to find out that something is not doing what you think it should be doing.

I just had this experience. I was working hard on a website but part of the layout was turning out totally weird. Somehow a table was ending up enveloping more than it should. This came about because a ColdFusion tag was not doing what I thought it should be doing. Even re-reading the documentation it seems that it should be working like I thought it should.

Okay, the tag? CFTRY. Now maybe this is something that is already documented but I've never seen anything about the problem I ran into. Matter-of-fact the documentation says it should be working exactly as I think it should. But it doesn't.

The documentation says that you put code that may cause an error inside cftry tags then use cfcatch to deal with errors. So what does this tell us? That IF there is ANY error inside the cftry area then it will go to the cfcatch without processing anything. Not so.

Here is what I had
< cftry >
< table >
[call API ] [ parse results ] [ display results ]
< /table >
< cfcatch >
No Results
< /cfcatch >
< /cftry>

Now I look at that if the API call or the parsing results in an error this will fail into the cfcatch and show "No Results". Not so. After much messing with the borders etc to see what exactly was being displayed, I found that the table tag was actually being processed. So inside a cftry tag everything will be processed UNTIL it hits an error. This is NOT what the documentation leads you to believe. So of course I just had to move the table tag after the parsing function and it worked as I wanted it to. But I burned a WHOLE lot of time figuring that one out.

Labels: , , ,

Wednesday, January 20, 2010

Bring in the APIs!

I am finally opening up my big project. Not pretty yet but it is functional so far. It has passed through months of testing and sobbing and pounding of head on monitor. But here it is. I'd love to see if you can break it.

What does it do? It combines shopping APIs from all over the place. eBay, Amazon, LinkShare, Commission Junction, Valore and many others to give the biggest internet comparison shopping site around. Is it slow? Not really. That took the most work but I did it with ColdFusion 8 and cfthread.

First thing I did was to build the API search functions into a CFC. Make the cfc an application object since it is used by everybody all the time. 1 function for each API. When run in sequence it was taking up to 1 minute to get any results. What was I to do?

Okay, I did threads. Each api call is a thread. This also helped if there was an error along the way in any of them it wouldn't jam up the whole thing. So this got results in around 15 seconds. What I did to take up the time was put an intermediate page in. You enter your search and you go to this "doing search" page where you see advertisements for other products. The searches themselves are actually happening in an iFrame that is 1px by 1px. When it is done loading it redirects the parent page to the results page.

BUT where are the results? To keep from jamming up my server memory I decided to jam up my database instead. Everybody who comes on the site gets their own temp table that holds the results of their searches. This way subsequent searches to narrow down the results are faster and easier. Of course this leaves the problem much like abandoned shopping carts. No biggy tho. Same solution. On session end the table is dropped. If that doesn't get it I have a scheduled task that runs every hour that clears out any tables that are over 2 hours old, which just happens to be the same as the session time out.  I seriously doubt anybody is going to be searching on my site for over 2 hours. But if they are they will get a new table because that is the first check I do in the onRequest function.

Anyway, it is still a work in progress but it is doing great so far. It is also the foundation for my entry into the PayPal new Advanced Payment API contest. Wish me luck on that. I have my application submitted for approval.

The site of my most awesome project? http://www.donomall.com/

Labels: , , , ,

Tuesday, January 12, 2010

ColdFusion has the wrong time?

My major bill paying customer has a variety of ColdFusion apps that I am upgrading to CF8 (and beyond!). One of them, the biggets and most urgent one, is on CFMX6.1 with JRE 4. 

Monday I get told that the time is wrong. It is 10 hours ahead. I immediatly think it is the server time has lost the GMT -10 (Hawaii). Nope. It is fine. For some reason ColdFusion is NOT seeing the GMT -10. I tried restarting the JRUN server. Nope. I went through all the settings and couldn't find anything.

Finally somebody was kind enough to point me to this article which shows how to fix it.

BUT while I was checking everything I found that there were errors in the logs saying the file structure was corrupted. So we ran a reboot with chkdsk, scandisk, crashdisk ... :) This corrected the problems and the time was now correct.

Good thing we are working towards updating this application to a new CF8/Win2k3 server in the next few days.

Wednesday, December 30, 2009

Editors who are clueless

Okay, I'm having a battle with eZineArticles.com. I have to tell everyone about this because it amazes me that they have an editor who is totally clueless about how URLs and websites work.  My beef is not about the article that has been there for years and suddenly a clueless editor decides to ban it for "redirecting from a subdomain".  What he actually means is redirecting from anything other than the root domain but that is the least of his problems.

I have a link that points to a tool people can use in one of my articles.  Of course I want to keep track of the clicks on the link so I make it go to my own click tracker. Why pay for one if you can build one? lol

So the links look like this http://www.donomite.biz/?999 (that is a bogus one of course).  Now he has been insisting that the ?999 makes it a subdomain.  At first I was patient and explained what a subdomain is and what the ?999 is; a url query.  Nothing doing. He came back and said it was a subdomain pure and simple.  And now he reviews other articles I wrote and sees the same thing and says they are all subdomains too.

Now I have gotten nasty with him. I told him how he is stupid and needs to take an HTML 101 course. If this guy was not in a position of authority, it would not bother me in the least but he has the power to take down articles thus I have little patience with him.  Anybody who declares themself an "expert" needs to have the knowledge to do the job. I am an expert with ColdFusion but I still learn things everyday about it and am not troubled by going and asking for help.  That is what makes me an expert, knowing where to find out what I don't know. :)  Even the people I turn to don't know everything and they are willing to learn also. This is how to handle these situations.

This editor should have gone to somebody and said "is this true?" and then apologized to me for being wrong. But instead he just keeps saying "IT IS A SUBDOMAIN".  Thus he should be removed from his position and my article left alone.

Tuesday, December 29, 2009

Google Analytics and ColdFusion 8

I have a customer who I built a tool to grab info from Google Analytics and insert data into a database. Why they wanted to do this is beyond me. They can actually get the exact same info from GA. But who am I to argue with a paying customer?
Anyway, back when I created this the only way to get the data was to have Google email it and then extract it from the xml file that was attached to the email. But then Google changed how they did the emails and it broke. But they didn't tell me for almost 8 months that it wasn't working.  So when they did I told them we should upgrade to the new api. What a mess!

Thanks to Jen's Bits I got a good start on how to do it. I didn't have to figure out the authentication portion. After that tho, it became dicey. Jen's example shows how to get a list of the accounts and the overall visitor count but nothing more. I had to go back and wade through the GA documentation, which is not easy. They do things really squirrley like geeks gone mad trying to come up with a new way to do APIs.  Please, geeks, stick with what is already known and make it easier on us working stiffs. I hate having to figure out what you are talking about when you say "segmentation" and "ids". Spell it out with examples. Then we have the problem of tacking on ga: to the front of all the variables.

First thing to figure out is there are 2 basic classes of queries you can run on the GA API, Metrics and Dimensions. Metrics you can probably figure out but "dimensions"??? Turns out you can mix and match what you want to pull up but only certain mixing and matching. Some metrics queries can not have certain dimension queries. And vice versa.

And then, you have to put in filters. They MUST be url encoded and they show you what those are in a table.

So to pull unique visits for a specific page you have to do something like this:
https://www.google.com/analytics/feeds/data?ids=ga:1234&metrics=ga:newVisits&dimensions=ga:PagePath&filters=ga:PagePath%3D%3D/blog/blogpage.cfm&start-date=#startDate#&end-date=#endDate#"

The dates must be formatted like yyyy-mm-dd.
The ids=ga:1234  That is the id for the website you are accessing. Where do you get that? From the basic call that you can find at Jen's Bits. It is in there, you just have to pull it out, which is not part of the code given there. But basic xml skills make it a no-brainer.

Now you see my metrics are newVisits so I tell it that is what I want by appending ga: to the front of it. There is a list of what you can call in the tech documentation. Notice how I had to say the "dimensions=ga:PagePath" and instead of having it simple like just "ga:PagePath=/blog/blogpage.cfm" (fictition page, just do a path from your root) it takes 2 steps. The next is the filters query to say what the path is. "filters=ga:PagePath%3D%3D/blog/blogpage.cfm".  That is a "==" in there. You can do other filters of course.

Then I wanted to do the home page. index.cfm  Do you think the path is just index.cfm? No. It is /index.cfm  So you have to think of it like http://www.mysite.com/ and take the path with everything after the "m" in "com".  So start with the "/" and go from there.

One key thing is that your page must have the GA code on it.  Seems obvious but not so it seems from people doing this in php, java, ruby etc. Of course thn they are not in their right minds anyway since they are'nt using ColdFusion. :)

Finally, I noticed the results were not the same as what is in the actual GA website. Off but not by a whole lot. I can chalk that up to the data is not up to the minute accurate in the api call.

Friday, December 18, 2009

Changes

I am switching this blog to ColdFusion and development work. I may still throw in some marketing techniques but I am so wrapped up in doing CF development that I haven't had time to write articles about internet marketing lately.

So let me get everyone up to speed on what I am doing and I will walk you through the processes and learning I am going through.

First, PayPal announced a new api that allows more flexibility in payments. Like parallel payments and string payments and much more. This is great! Or is it? Only downside I've seen is that it all has to be done in PayPal. No credit cards. BUT most people have shopped on eBay and have a PP account kicking around somewhere.

Along with this they have a $150k contest for best new application using the new api's. Submissions of ideas had to be in by Dec 16th. I entered 1 because I was already working on it and the new api fit in beautifully.

What am I doing? 2 things that are closely related but different. First is a shopping mall. This is more than just a comparison shopping site, I have stores with products, working on coupons, and of course advertisements. The comparison shopping part utilizes the api's of Commission Junction, LinkShare, BestBuy, Amazon, and eBay right now to search 1000+ stores for whatever you want. In addition you can go into the mall and see a tabbed page (ColdFusion 8 at work) showing stores like WalMart, Fujitsu, and others with their latest and greatest. I am currently trying to make the Linkshare coupons api work but they limit it to 50 calls per day. ughh. So I have to create "hard" copies of everything to put it on my site. Basically I do the call for 2 areas: by promotion type and by category. Then build cfm pages with that information and put it all in cflayoutareas. Right now it isn't working quite right but I seem to run out of calls before getting the testing done. I am thinking I just need to make the calls needed and store the info so I can then just pull that into my site.

That site is http://www.donomall.com/

Then I am doing a revision to my textbook site. Same basic concept but narrowed down to just books. I say it is for textbooks but you can search for any book in there. I use the same search cfc but limit it to books. Plus I have thrown in an ISBN look up function because ISBNs are much more exact when looking for a book.

That site is http://textbooks.donomall.com/

Now the textbook site is where I am using the new PP api. Basic idea is to give people the ability to list their own textbooks for sale and have them included in the search results. The first step is to sign up and list your book which costs a $5 refundable deposit (minus $1 service (PP) fee). If they sell the book through my site then they get $4 refunded. I take a small percentage of the sale price. Thus the string payment. If they don't sell it through my site then they forfeit the deposit.

That is still in development since it has to be approved by PayPal before it can go live. What I am throwing into place in the meantime is a simple $2 charge to list the book. This can be done with PP website basic so no need for approval.

I've learned so much about ColdFusion 8 while doing these projects and I will try to share as much as I can. Right now I am working on a Google Analytics piece for a customer plus still working as Adobe specialist at the Pearl Harbor Naval Shipyard.