Building a Facebook app on a host without HTTPS/SSL Support

Recently (Yesterday) I was confronted with the ugly fact that Facebook REQUIRES SSL for your application. Now there are quite a number of free services out there that give shared ssl support, however, I was quite happy with my current hosting provider and did not want to shift my database and files to a group I knew nothing about. So here is an extremely simple and easy to do tutorial for everyone who feels the same.

The Realization

After playing around with Facebook, I realized that I can navigate away from HTTPS at any time. Its only required by Facebook that the URL you enter into Facebook for your app is an HTTPS url. And that gave me the idea for a simple redirect script!

The Requirements

Now, unfortunately, you still need some provider with some sort of ssl. Fortunately, Heroku does just that and was quite simple to setup and its free (And no, you don’t have to move your application over to them, keep reading). If you’d like to use another provider, or maybe you own a server with ssl support, you are most welcome to use that instead.

The Code

Now create a php file with the following code:

<?php
header( 'Location: http://www.xethron.co.za' );

The Facebook

Point your SSL link on Facebook to this php file, and tada! Facebook accepts the url, upon loading the URL in the iframe, php redirects it to your non-ssl application, and none of your code had to be moved anywhere.

Hope this helpes someone!

DISCLAIMER: This bypasses SSL for your Application and thus decreases the level of security. However, for a testing environment, and for most “non-personal” information, this should be perfect for your needs…

MDS Collivery Shipping Module for WooCommerce

What started of as a small WordPress project for a client quickly turned into something much bigger (and really exciting) after getting in touch with the person in charge for the API of MDS Collivery, and asking for his assistance.

Introduction

We where working on a WordPress eCommerce (Jigoshop) website for a client that asked if we could write them a simple plugin that would get the shipping price from one of South Africa’s local shipping companies, MDS Collivery, and add it to the total. While working on the plugin, I ran into some trouble, and contacted MDS to ask if they can assist. I was put into contact with Dale who proved very helpful and later asked if I can’t help them make an official plugin for WordPress (Jigoshop).

Having gained some experience from the previous attempt, and a larger budget, I accepted this challenge and decided to start from scratch and do something proper that can be used as a basis for all other plugins! I did some research and looked at all the eCommerce plugins available for WordPress. As I’ve had a very bad experience with Jigoshop support, I tried to convince Dale that we shouldn’t go for Jigoshop first. After trying a few out, I realized that WooCommerce is a fork of Jigoshop, and has much better support and features. Looking at previous emails, Dale agreed that he has more requests for a WooCommerce plugin, than Jigoshop plugins. And thus, development was started!

Development

Except for their current Joomla plugin for VirtuMart, this was the first of its kind. And luckly for me, Dale was very easy going on the outcome of the plugin. They wanted the price to be added to the total (as with the Jigoshop one), and they wanted the admin to be able to register the shipping with their API in one click. Although there are a lot of features we still wish to add like, tracking your shipping progress and more flexibility, this was a good start to play around with the features of WooCommerce and see what can/can’t be done.

I found out that WooThemes (Creators of WooCommerce) where based in South Africa, and where more than ready to help a fellow developer. This was a HUGE improvement to Jigoshop where the answer was always “Look in the code, its well commented” after having paid 500 USD for support. Great way to spend your money if you have 500 USD you want to throw to the fishes!

The Plugin

Ok, sWooCommerce Checkout Screeno the part you all want to read is this. As MDS has a list of names for towns and suburbs, and has a few extra fields (Like building type), I replaced all the standard checkout fields with already populated fields from MDS. This makes it very easy to check out by simply choosing locations from the drop down menu’s. However, this caused the information in the admin side to be useless like: Address – 336 Church Street, PTA, 4467, 1. So, instead of using their ID’s as values for my lists, I decided to use the names, and then look up the names for the ID’s afterwards. This made it a lot more readable for the admin and other plugins if they wish to use the address/contact fields.

MDS Admin ScreenThe only other thing added was a page to register the shipping from within the order. The admin can go through all the orders, and simply click “Register Shipping”, and all that information will be sent to MDS, and they will arrive at your door hungry for what you have to offer. No phone calls, no emails, no questions asked.

I then spoke to Dale about releasing this under the GPL3 license and placing it on GitHub to allow other developers to join in on the fun and customize it to their requirements without breaking updates.

Get the Source

The plugin was recently uploaded to GitHub and, while still in Beta, free for everyone to use and try out. Check it out here: https://github.com/Xethron/wc-mds-collivery

If you have any questions, bugs and/or feature requests, you are most welcome to leave a comment or submit an issue on GitHub.

How to Install the latest Nemo from Source (GitHub)

If you like Bleeding Edge, then you have come to the right place! In this howto we will take a look at how to install the latest version of Nemo on GitHub. But be warned, its not always well tested fully tested (Hence the name Bleeding Edge!).

Install all the packages needed to compile Nemo

The following tools are needed to compile from source

sudo apt-get update
sudo apt-get install gtk-doc-tools libgail-3-dev libnotify-dev

Git the latest source code

You can setup your own fork of Nemo, or use one of the many already available. Here is the latest code from the official linuxmint repository.

git clone git://github.com/linuxmint/nemo.git

Compile and install!

cd nemo/
dpkg-buildpackage -d -b
cd ..

Make sure you removed all the previous Nemo installs!

sudo apt-get purge nemo nemo-data nemo-dbg libnemo-extension1a

The following command shouldn’t return anything if everything is removed

sudo dpkg -l | grep nemo

Install your freshly compiled Nemo!

sudo dpkg -i nemo*.deb libnemo*.deb gir*.deb

To check if you have the latest version, do a

nemo --quit
nemo --version

Here is a good tutorial on how to install Cinnamon and Muffin from Source: http://community.linuxmint.com/tutorial/view/955

Personally, I use all of autarkper’s repo’s as they are usually one step ahead in terms of features and bugfixes: https://github.com/autarkper

Have fun and remember to report any bugs to GitHub!

Setting up Git

NOTE: There are already many articles like this on the internet that describe this process in detail. The main reason for this post is as a reference for myself and others that already understand the basic structure of Unix and Git to make sure everything is set up. It is NOT FOR BEGINNERS!

For this post, I assume you have a fresh install of the latest Git (Not GitHub) on your computer. You can get it from http://git-scm.com/downloads

Setting up Git is really easy if you know all the commands. First, we want to set your name and email so that other users know who you are. (This is only for identification purposes)

git config --global user.name 'Bernhard Breytenbach'
git config --global user.email 'name@example.com'

If you want Git to remember your passwords for some time, use:

git config --global credential.helper cache
# Default timeout is 15 minutes
git config --global credential.helper 'cache --timeout=3600'
# Set custom timeout to 1 hour (in Seconds)

Generate SSH Key for password-less login [Read More]

ssh-keygen -t rsa

This will create two files in your .ssh directory. id_rsa and id_rsa.pub. id_rsa is your private key. This is a top secret file. Keep it safe! id_rsa.pub is your public key. Add it to your server’s authorized_keys file.

To setup git on a server, check out this tutorial!

Thats it. Next we will take a look on how to customize our setup for effective Web Development! Feel free to leave a comment if you think I missed anything!

My first post

Finally got my very first WordPress blog running after having to update to PHP 5.3. Had to reduce the amount of resources allocated to apache httpd, so hope its still enough to provide my 5 fans with quick and easy access! :P

My idea (and hopes) for this blog is to be a quick, to the point resource of all the problems I faced with regards to Programming and Open Source Software. Also, as the company I work for (Assemble Online) mainly uses WordPress to create websites, I hope to learn something about the way WordPress works, as well as how to write my own plugins.

As I don’t really have a post right now (Always have ideas for posts until I get my blog running, pfft), I thought I’d make a boring post on whats been happening in my life that got me to start this blog.

I started a page called “Android Reviews” while still in University when I was still a Google Student Ambassador. Didn’t really take it seriously, but it turned out to be a huge success, with over 1000 followers. (Really want to get that going again)

I recently started working for Assemble Online as a Junior PHP developer. However, I last used PHP4 with Joomla and Mambo, so I quickly had to learn PHP5 with HTML5 and CSS3. They also use WordPress as a CMS (Yet another tool I don’t know).

Also, as the University required Windows as a Operating System, and I never had enough space for backups, I haven’t used Linux since 2008… So figuring out what distro (Linux Mint), desktop environment (coz gnome useless, and Cinnamon is awesome) and what programs to use and remembering all those commands was a bit of a set back. But its great being the only Linux User between all these “Mac fans boys”, showing them how its done. ;)

I was asked to setup a form of version control for the company, and looked into using GIT (Best SCM EVER!) I watched a few videos on Lynda.com and setup a server for us.

I was also asked to create two plugins for Jigoshop, “a WordPress eCommerce plugin that works”. This gave me some insight into Jigoshop and WordPress, and showed me how useless the Jigoshop support for developers are.

I was also asked to do some research on frameworks and choose one to use. I took a look at CodeIgniter, Zend, Laravel, and Yii. Currently I’m using the Yii Framework, and still have a lot to learn. But would love to take a look at the other 3 when I have time.

So yeah, here I am, a sucker for code and anything IT’ish, and I hope to paste some content that you could find useful one day.

If you read this line it means you ether skipped to the end (loser) or you read the entire article (don’t you have a life?). Ether way, thanks for reading :)

Bernhard Breytenbach