Saturday, March 22, 2014

Getting Caspio data out to share on Facebook

I've been building an Austin Happy Hours database using Caspio, coming across a not-new challenge where I want to pull data out of Caspio results to use elsewhere on the pages, in this case for Facebook sharing.

It's a special challenge with Facebook, because they want you to use of Open Graph metatags in the of pages to control things like the title, image, share url and description of your content. And while sharing services like AddThis and ShareThis have customization options for these, Facebook doesn't honor them because of this insistence on using og: tags. In other words, those services have the same challenge I do.

I first tried to set javascript variables in my Caspio results to use once the datapage has loaded, which I've used successfully for Google Maps, DocumentCloud and other APIs. While I could append the new metatag to the head using jQuery, Facebook wouldn't honor them. I think that's because Facebook had already processed that part of the page, but I could be wrong.

What ended up working is to include my venue title in the URL of my detail page, so I could then parse it out using PHP and then use to write the metatag when the page was processed. This only worked for me because:

  • We recently got access to publish projects on an PHP server. (We don't have access to any server-side processing from within our CMS.) Without the server-side processing, I'd be out of luck.
  • The page where I wanted this was a Detail report form Caspio, which is drawn when I pass a parameter through the URL into the detail datapage. If I was using a normal Search and Report page, I wouldn't have the content I need in the URL.

There is a downside to this, in that my URL is really long, especially for Twitter. AddThis doesn't use a shortener (at least in their free service.) I started this project using ShareThis, who shortens the url for Twitter, but the ShareThis code was so slow loading I ended up abandoning it for AddThis.

Here are some of the details. I suspect my code is brutish, especially where I search and replace for things like commas, etc. That will break when I get a character I don't expect. I bet there is a PHP command that would do that for me? Please comment if you have a suggestion on that.

Monday, March 03, 2014

Notes from NICAR 2014

This was my first NICAR conference, which has a focus on data-driven reporting and other technical aspects of our craft. The IRE conference usually has similar content, but is also broader in scope.

Here's the full schedule from NICAR 2014 and from IRE 2013 last year. This year's IRE 2014 will be in San Francisco on June 26-29.

But back to NICAR 2014. Here are the goods:

Here is a quick list of the panels I went to and what I got out of them.


Before NICAR in Baltimore, I also went to Tapestry, a data visualization conference sponsored by Tableau. Unlike the 900+ NICAR, Tapestry was limited to about 100 participants, all on the same tract. Speakers included Alberto Cairo, Aron Pilhofer, Fernanda ViĆ©gas and Martin Wattenberg and a host of others. It was good for inspiration, connections and a preview of Alberto's talk at NICAR, allowing me to double up on some content.


  • Since I had seen Alberto's talk the day before, I could skip the first part of my D3 News camp to take some MySQL: I actually took two courses on this, which was more any overview of how a database manager can help you vs. Access, and an intro to Navicat, a paid tool to use a MySQL database. It went a little slow for me, but I did enjoy CIR's Chase Davis' take on it.
  • I hoped into the last part of the Intro to D3 talk, which really was a panel walk through of basic code, and I suffered from not being at the beginning. Quickly reviewed notes and hoped I would be OK for afternoon hand-on session.
  • Afternoon D3: In short, this helped me understand the structure of D3 better, but didn't build any proficiency and I would have trouble creating the most simple viz now. But it was better than not going.


  • Three hour-long sessions on statistics. The intro was really a get-to-know SPSS, a powerful and expensive statistics software package. We didn't get to the most important part of comparing two types of categorical information, so I felt like we missed out a little. The next session on comparing two continuous fields (linear regression) was awesome, and the third on comparing a categorical and continuous information (logistic regression) was also valuable.
  • Since I didn't get much actual SQL on Thursday, I chose the Intro to SQLite class and got the best tip of the conference: you can run SQLite in Firefox using the SQLite Database Manager, with no other software to install (at least on a mac.) This might be how I teach SQL in Data-Driven Reporting next year.
  • Next I helped Scott Klein (ProPublica) and Michelle Minkoff (AP) teach a session on grabbing data from the web.
  • Last was the lightening talks, 10 quick talks. It was a packed room ... well over 800 people. They were all good ... 


  • Building a data-journalism course. One of the panelists from Maryland has his students work on the same data set so they can help each other. Amanda Hickman works to get more basic data and viz/charts in earlier courses so students have familiarity so they can get further in class. A couple have groups of students working on the same long-term project or different parts of same subject. Canadian used a donuts to describe databases (then ate them).
  • Clean, clean, clean your mess. Regular expressions class was helpful for this. I had no problem with the code, but had some problems with teaching style. Cleaning data class introduced OpenRefine and class after was helpful in reinforcing those skills. Refine is awesome.
In between all this I made spent good time with folks from the Canadian Broadcasting Company, Orlando Sentinel, Huffington Post, Pixar/Paramount, the Texas Tribune, the AJC, Dayton Daily News, Seattle Times, the Vancouver Sun, small papers in Pennsylvania, South Carolina and god knows where else. And speaking of God, some good bar time with gentleman attending a Catholic youth ministries and a different time with vets getting training at Veteran's Affairs. Also several folks from various schools and many more I'm just not remembering.

My eyes were opened to some database structures, and skills refined for Refine, which I proceeded to crash time after time for four hours straight working on a huge dataset. The statistics classes were well worth it, too ... I know I need to learn more, but that is OK.

  © Blogger template 'A Click Apart' by 2008

Back to TOP