Uncategorized

First Post in 2014 on the Last Day of 2014 :D

Wow! It’s been a wonderful year! I have learnt so much this year and I’m excited because greater things await me in 2015!

I’m not gonna promise again like I did last year to post regularly but I do think it would be great from me to continue to share my learnings so others can benefit from it.

What else can I saw but to wish you a Happy & Fruitful 2015!

God bless you.

Standard
Uncategorized

Wow! How time flies when you are having fun!

It’s incredibly how time flies when you are having fun. It has been over a year since my last post and it feels good to be back. I’ve been playing around with cool tech like Amazon Web Services, Adobe Air, Android, Windows Phone, Azure and a host of other things. 

I’ve fallen in love with some and others are great in their own way. Fortunately I now have some new interesting things to share so watch out for some new posts 🙂

Standard
Uncategorized

Beginners guide to consuming a web service using PHP SoapClient

In this example we’ll call a free public weather web service and get the current weather in Lagos, Nigeria.
 
The WSDL is for the web service is
 

The Web Services Description Language is an XML-based interface description language that is used for describing the functionality offered by a web service. A WSDL description of a web service (also referred to as a WSDL file) provides a machine-readable description of how the service can be called, what parameters it expects, and what data structures it returns. It thus serves a purpose that corresponds roughly to that of a method signature in a programming language. (Wikipedia)

Fortunately we don’t need to read the raw WSDL to get cracking. 
 
The code below demonstrates how to call this web service to get the weather in Lagos, Nigeria. 
$client = new SoapClient($url);
$fcs = $client->__getFunctions();
debug($fcs);
$res = $client->GetWeather(array(‘CityName’ => ‘Lagos’, ‘CountryName’ => ‘Nigeria’));
 
So let me explain a bit. 
 
First thing we need to do is create a new SoapClient http://www.php.net/manual/en/soapclient.soapclient.php
$client = new SoapClient($url);
 
The next step is not required but I do this to get a simple definition of the functions available in the web service.
$fcs = $client->__getFunctions();
debug($fcs); // This is a cakephp function. You can use var_dump instead or any other function you like.
 
I do this so it provides me the all functions available in the web service in a pattern I can understand. Below is what is returned.
array(
	(int) 0 => 'GetWeatherResponse GetWeather(GetWeather $parameters)',
	(int) 1 => 'GetCitiesByCountryResponse GetCitiesByCountry(GetCitiesByCountry $parameters)',
	(int) 2 => 'GetWeatherResponse GetWeather(GetWeather $parameters)',
	(int) 3 => 'GetCitiesByCountryResponse GetCitiesByCountry(GetCitiesByCountry $parameters)'
)
From here we see that the web service has 4 functions we can call. It also tells us the request parameter data types we need to send and also the data type of the response we’ll get.
 
So lets look at the first function 
GetWeatherResponse GetWeather(GetWeather $parameters)

The function name is GetWeather, the parameter is of type GetWeather and the response is of type GetWeatherResponse

 
We can call this function thus: 
 
$response = $client->GetWeather($parameters);
 
First we need pass the appropriate parameters. Fortunately the web service also provides us the definition of each data type. To get this we need to look into the WSDL file. 
 
<script id=”tinyhippos-injected”/>
<wsdl:types>
<s:schema elementFormDefault=”qualified” targetNamespace=”http://www.webserviceX.NET“>
<s:element name=”GetWeather”>
<s:complexType>
<s:sequence>
<s:element minOccurs=”0″ maxOccurs=”1″ name=”CityName” type=”s:string“/>
<s:element minOccurs=”0″ maxOccurs=”1″ name=”CountryName” type=”s:string“/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name=”GetWeatherResponse”>
<s:complexType>
<s:sequence>
<s:element minOccurs=”0″ maxOccurs=”1″ name=”GetWeatherResult” type=”s:string”/>
</s:sequence>
</s:complexType>
</s:element>
 
 
Above is the definition of the GetWeather and the GetWeatherResponse data type. Notice that the GetWeather data type is a sequence complexType with two elements CityName and CountryName. Basically this means that in PHP you’ll pass an associative array with keys CityName and CountryName and having values of type string. Therefore our call to get the weather in Lagos will be 
 
$res = $client->GetWeather(array(‘CityName’ => ‘Lagos’, ‘CountryName’ => ‘Nigeria’));
 
 
Here is a sample of the response 
object(stdClass) {
	GetWeatherResult => '<?xml version="1.0" encoding="utf-16"?>
<CurrentWeather>
  <Location>Lagos / Ikeja, Nigeria (DNMM) 06-35N 003-20E 38M</Location>
  <Time>Dec 04, 2013 - 03:30 AM EST / 2013.12.04 0830 UTC</Time>
  <Wind> from the NW (320 degrees) at 6 MPH (5 KT) (direction variable):0</Wind>
  <Visibility> 4 mile(s):0</Visibility>
  <SkyConditions> partly cloudy</SkyConditions>
  <Temperature> 80 F (27 C)</Temperature>
  <DewPoint> 75 F (24 C)</DewPoint>
  <RelativeHumidity> 83%</RelativeHumidity>
  <Pressure> 29.97 in. Hg (1015 hPa)</Pressure>
  <Status>Success</Status>
</CurrentWeather>'
}
This is as defined in the WSDL i.e. GetWeatherResponse is a sequence complexType having an element GetWeatherResult. The value of the element is an XML document which can be parsed easily. 
 
This example is a bit complicated because of the use of complexTypes. Some web services take string parameters hence that would be very straight forward.
 
Hope this helps. Please leave a comment below if you have any issues with this and I’ll get back to you.
 
Cheers!
Standard
Uncategorized

New Tools for Web and Mobile Application Development

I recently started investigating new tools available for mobile web development and I ran into a plethora of tools. From JS MVC frameworks to js templating engines, and css extensions. I thought it would be a good idea to share the list I’ve discovered so far. Please add a comment for any js library I’ve missed. Thx

JS Tools

Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions,views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
http://backbonejs.org/

Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects. It’s the tie to go along with jQuery’s tux, and Backbone.js’s suspenders.
http://underscorejs.org/

Thorax, An opinionated Backbone application framework providing a filesystem structure, on demand module loading, model and collection view binding, inheritable view and DOM events, data loading helpers, form serialization / population and validation. Built using Backbone,Underscore, Zepto, Handlebars, Stylus and Lumbar.
http://walmartlabs.github.com/thorax/

Sugar is a Javascript library that extends native objects with helpful methods. It is designed to be intuitive, unobtrusive, and let you do more with less code.
http://sugarjs.com

Zepto is a minimalist JavaScript library for modern browsers with a largely jQuery-compatible API. If you use jQuery, you already know how to use Zepto.
http://zeptojs.com/

Scroll 4 is a complete rewrite of the original iScroll code. The script development began because mobile webkit (on iPhone, iPad, Android) does not provide a native way to scroll content inside a fixed width/height element. This unfortunate situation prevents any web-app to have a position:absolute header and/or footer and a scrolling central area for contents.
http://cubiq.org/iscroll-4

Lumbar is a js-build tool that takes a general codebase and list of platforms to generate modular platform specific applications.
http://walmartlabs.github.com/lumbar/

JS Templates

Mustache, Logic-less templates.
http://mustache.github.com/

Handlebars provides the power necessary to let you build semantic templates effectively with no frustration.
Mustache templates are compatible with Handlebars, so you can take a Mustache template, import it into Handlebars, and start taking advantage of the extra Handlebars features.
http://handlebarsjs.com/

CSS Extensions

Sass makes CSS fun again. Sass is an extension of CSS3, adding nested rules, variables, mixins,selector inheritance, and more. It’s translated to well-formatted, standard CSS using the command line tool or a web-framework plugin.
http://sass-lang.com/

Stylus, Expressive, dynamic, robust CSS
http://learnboost.github.com/stylus/

LESS extends CSS with dynamic behavior such asvariables, mixins, operations and functions. LESS runs on both the client-side (Chrome, Safari, Firefox) and server-side, with Node.js and Rhino.
http://lesscss.org/

Standard
Uncategorized

From Zero to Alpha

Seems I’ve been living in a bubble and time has been flying. Fortunately I learnt a lot while in that bubble and I’m looking forward to sharing some of the stuff I’ve learnt or I’m reminded of. From trying my hands out with Android development to pitching to VCs, I’ve begun to realize how important it is to not delay in implementing your ideas. Yes they are a dime a dozen but there a few ones that get you excited. Surfing on that exciting is something I enjoy a lot and I’m longing for more. 

I’ve learnt you really don’t need to figure everything out before you start working on your idea apart from if it meets real people’s needs. Does it meet your needs? Is it just you or do you see 10s, 100s or 1000s or even 1Ms of people out there you’ll be meeting the needs of. If you can see some people enjoying your solution and you’ve got the time I’ll most definitely suggest you give it a shot but keep your day job. Create your prototype and see how it goes. And most importantly, enjoy your solution!

Standard
Uncategorized

Quick Introduction to jQuery Mobile

By popular demand, I’ve been working on several mobile applications in the last couple of months. I’ve come to love jQuery Mobile (jQM) for it’s simplicity and ease-of-use. I also love the rich UI components, tools that make creating apps easy, much more. A super cool friend, Adegbenga Agoro, asked for a short introduction to jQM and this post is a result of that intro. This is a sharp-sharp (Nigerian slang for quick) introduction to jQuery mobile. It showcases my favorite tools and resources for working with jQM.

Where to start? http://jquerymobile.com. It’s got everything. Demos, docs, tips, device compatibility etc.

Tools & Tips

jQuery Themeroller

Create Theme Swatches for jQuery Mobile Interface. Allows d rag and drop of colors to UI components.Update existing themes by importing css. Allows export of themes in css format & includes icons.
http://jquerymobile.com/themeroller/index.php

Mobile Apps > PhoneGap

Want to great Mobile Apps? Compile jquery mobile webapps using PhoneGap [http://phonegap.com]
Goto http://build.phonegap.com

Prototyping > Codiqa

Create prototypes quickly with a simple, intuitive drap-and-drop interface. Free trial available. SaaS

Quickstart Workflow

1. Create theme with jQuery Mobile Themeroller and export

jQuery Themeroller in action

jQuery Themeroller in action

You can also import existing themes.


2. Import theme into Codiqa



3. Create app prototype in Codiqa



4. Download prototype, customize and start adding functionality.

Please leave a comment if you’ve found this useful and if you have any questions.

Standard