Featured Posts

FuelPHP Command Line Oil with Windows BAT File And... I have been using the Codeigniter PHP MVC framework for awhile now and have started to realize I need some extra features that are not built in by default.  A few weeks ago...

Readmore

PHP Class To Build HTML Forms I have recently pushed a new repository to Github to showcase a PHP class I built.  This class helps make building HTML forms easier.  I originally built this class to help...

Readmore

Codeigniter Library to Read CSV File I recently posted some code to Github that I created for use in Codeigniter. I built a library that can be used to read CSV files, extract the data you need, and return a...

Readmore

Using PHP Curl To Check Apple Site To See If My Extension... A few weeks ago (probably closer to months now) I built a Safari extension.  I also submitted it to Apple to see if it can be listed on their Safari extensions page.  I...

Readmore

Safari Extensions - Puni.co URL Redirection For anyone interested in URL redirection services and Safari Extensions, here is a service offered by TheBizzTech LLC.  We have made a Safari Extension that uses the free puni.co...

Readmore

TheBizzTech Rss

Zend Framework Action Helper For Bit.ly

Posted on : 06-09-2012 | By : TheBizzTech | In : Github, Model-View-Controller (MVC), PHP, Programming, Zend Framework

Tags: , ,

0

Wow, I just realized it has been a long time since I posted on my blog.  If you care, it has been a few months since I left PayPal and I have been busy working at The Nerdery, mostly building Facebook Apps and the like.  I am going to keep this post short and sweet.

The other day at work I learned I may need to integrate with the URL shortening service Bit.ly.  My first reaction was why not use my own URL shortening service puni.co, and then I remembered I built that along time ago and never added an API and do not keep up development on it, so that idea was dead.  Just as a little back story, as you may have guessed from the title, I mostly use Zend Framework now, because The Nerdery does and also because I used to only use Codeigniter but have come to love the power and flexibility of Zend.

Back to the main story.  Once I learned I may need to use Bit.ly, I thought this would be the perfect time to build a class, or Action Helper on my own time since another project I am working on will be using Bit.ly, so was born my action helper found on Github.  It was not until after I spent about an hour building this that I realized Zend already has nearly the exact same implementation already built in.  After thinking about it I realized that is ok because they only built in the shortener part of the API, where I can now add more of Bit.ly services as I need then.

Enough talk, here is the code. Enjoy!!

CAUTION: If you are new to Zend and do not understand some of what I did then go to GitHub and read my README notes on implementation.

<?php
/**
 * Action helper to use with Bit.ly url shortening service
 *
 * @category 
 * @package 
 * @subpackage 
 * @author     Jason Michels
 * @link      http://thebizztech.com
 * @version $Id$
 */
class Zendtest_Controller_Action_Helper_Bitly extends Zend_Controller_Action_Helper_Abstract
{	
	protected $apiUsername;
	protected $apiKey;
	protected $apiEndpoint;

    /**
     * Filter n array.
     * 
     * @return void
     */
    public function __construct($bootstrap = null)
    {
    	$this->apiUsername 	= Zend_Registry::get('config')->bitly->apiUsername;
		$this->apiKey 		= Zend_Registry::get('config')->bitly->apiKey;
		$this->apiEndpoint 	= Zend_Registry::get('config')->bitly->apiEndpoint;
    }

	/**
     * Shorten long url
     * 
	 * @param $longUrl string
	 * @param $domain string
     * @return void
     */
	public function shorten($longUrl, $domain = false)
	{
		$url = $this->apiEndpoint . '/v3/shorten?';
		$url .= 'login='.$this->apiUsername.'&apiKey='.$this->apiKey;
		$url .= '&longUrl='.$longUrl;

		if($domain){
			$url .= '&domain='.$domain;
		}

		//Use cUrl
        $curlConfig = array(
            'adapter'       => 'Zend_Http_Client_Adapter_Curl',
            'curloptions'   => array(CURLOPT_FOLLOWLOCATION => true),
        );
        $client = new Zend_Http_Client($url, $curlConfig);

        $response = $client->request("GET");
        $response = json_decode($response->getBody());

		return $response->data->url;
	}
}

FuelPHP Command Line Oil with Windows BAT File And XAMPP

Posted on : 23-08-2011 | By : TheBizzTech | In : FuelPHP, Model-View-Controller (MVC), PHP, Programming

Tags: , , , , ,

48

I have been using the Codeigniter PHP MVC framework for awhile now and have started to realize I need some extra features that are not built in by default.  A few weeks ago I came across a Twitter post by Phil Sturgeon about a new PHP framework he is involved in called FuelPHP.  I started looking at it and realized it had a lot of the features right out of the box that I have been looking for.  It has things like Migrations, a Command Line tool, and HMVC.

I am not going to get into all of these features as FuelPHP has some decent enough docs to get you started.  What I am going to explain a little bit about is their command line tool called OIL.  For starters, those of you who know Ruby on Rails will be fairly familiar with the idea of using the command line.  There is a command simply called rails, in Ruby on Rails, that allows you to manage much of your app.  With Oil you can do things such as build scaffolding, inspired by Rails, run your own tasks, and build models and controllers.

Oil works perfectly well on *nix type machines, but I have had issues running PHP command line from Windows 7 and XAMPP.  Here are two ways I have been able to run Oil using Windows command line.  There is a way to be able to type just php from the command line by chaining the PATH, but for some reason I am not able to get it to work on my machine at all.  After many times trying I have just gone with the next two approaches.

When you run a PHP command on *unix you generally just have to type php followed by your commands; this however did not work for me on Windows running XAMPP.  The first way to solve this is instead of just typing php you have to type the full path to the php.exe file.  Since I am running XAMPP I would always have to type something like this “xampp\php\php.exe” every time I wanted to run PHP.

The second option is to run a batch file.  In the main directory of the FuelPHP package their is your file called oil.  In this same directory create a file called oil.bat.  In this file you will put the path to your PHP install and some command line helpers.  This text below is what I have in my oil.bat file and it basically looks for a file called oil and takes the arguments you entered and passed them to oil.


@c:\xampp\php\php.exe %~n0 %*

Note: this may be different for you depending on where you have XAMPP installed, and where your php.exe file is located.  Now to run oil you basically just run something like this from the command line.


oil.bat help

If anyone has an easy way to be able to fix my issue with running a simple php command from the command line let me know, otherwise these two options above should work just fine.

PHP Class To Build HTML Forms

Posted on : 29-04-2011 | By : TheBizzTech | In : Github, HTML, PHP, Programming

Tags: , , , , ,

4

I have recently pushed a new repository to Github to showcase a PHP class I built.  This class helps make building HTML forms easier.  I originally built this class to help make PayPal buttons easier to built into PHP scripts.  I have not looked at this script much since the summer of 2010, but hope to dust it off soon.

Here is a simple example of how to use the class that you can download from Github here, https://github.com/thebizztech/htmlform


<?php
/**
* TheBizzTech
*
* This example utilizes the open source htmlform PHP class built to make building HTML forms easier
*
* @author		Jason Michels
* @link		http://thebizztech.com
*/

//To use the htmlform class you first need to include the file
require("htmlform.php");
?>
<html>
<body>
<?php
// Initialize form class
$form = new htmlform();
// Begin the form and pass array of values
$form->begin_form(array("name"=>"myform","action"=>"index.php","method"=>"post","target"=>"thebizztech"));

// To create a new label include the element id in the "for" array value
$form->form_label(array("for"=>"1stid","text"=>"This is a label: "));

// To create an input field pass array with any standard attributes. The class will check to see which ones are set
$form->form_input(array("type"=>"text","id"=>"1stid","class"=>"1stclass","name"=>"1stname","value"=>"this is the value"));

// Another form input example
$form->form_input(array("type"=>"submit","id"=>"submitform","class"=>"submitform","name"=>"submit","value"=>"Submit Form"));

// Example of a form button
$form->form_button(array("type"=>"button","value"=>"Awesome","text"=>"Awesome button"));

// End of form. This will take one parameter allowing you to add html after the form such as a line in the example
$form->end_form("<hr />");
?>
</body>
</html>

Codeigniter Library to Read CSV File

Posted on : 26-04-2011 | By : TheBizzTech | In : Codeigniter, Github, Model-View-Controller (MVC), PHP

Tags: , , ,

8

I recently posted some code to Github that I created for use in Codeigniter. I built a library that can be used to read CSV files, extract the data you need, and return a PHP associative array.

Below I will post the code and a simple function that could be used in a Controller that would utilize the library.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * TheBizzTech
 *
 * An open source library built for Codeigniter to read CSV files into associated arrays
 *
 * @author		Jason Michels
 * @link		http://thebizztech.com
 */

class Getcsv {

	function get_csv_assoc_array($file_path, $questions)
	{
		$row = 0;
		if (($handle = fopen($file_path, "r")) !== FALSE)
		{
			while (($data = fgetcsv($handle, "", ",")) !== FALSE)
			{
				if($row == 0)
				{
					foreach ($questions as $key => $value)
					{
						foreach($data as $d_key => $d_value)
						{
							if($data[$d_key] == $value)
							{
								$q_location[$value] = $d_key;
							}
						}
					}
				}
				else
				{
					foreach ($questions as $key => $value)
					{
						$new_row = $row -1;
						$final_array[$new_row][$value] = $data[$q_location[$value]];
					}
				}

				$row++;
			}
			fclose($handle);
		}
		return $final_array;

	}
}

?>

Here is the example function:

function sample_read_csv()
{
	$this->load->library('getcsv');

	$data = array('name', 'email', 'id', 'transaction');

	$csv_array = $this->getcsv->get_csv_assoc_array("path/to/file.csv", $data);
	print_r($csv_array);
}

Right now this library only has one way of reading CSV files, but I hope to expand it over time.

To use the library you first have to load the library:

$this->load->library('getcsv');

After the library is loaded you have to create an array of column names that you know are in the CSV file and would like returned. Finally, call the library function and pass in the path to the file and the array you created, then print to see the results.

$data = array('name', 'email', 'id', 'transaction');
$csv_array = $this->getcsv->get_csv_assoc_array("path/to/file.csv", $data);
print_r($csv_array);

Let me know if there is any features you would like to see. You can find this code hosted on Github HERE.

Using PHP Curl To Check Apple Site To See If My Extension Is Listed

Posted on : 26-04-2011 | By : TheBizzTech | In : Curl, Mac OS, PHP, Puni URL Redirection, Safari, Safari Extensions

Tags: , , , ,

3

A few weeks ago (probably closer to months now) I built a Safari extension.  I also submitted it to Apple to see if it can be listed on their Safari extensions page.  I have not heard anything back for a while and have gotten sick of constantly going to their website and searching through the hundreds of extensions to see if mine has been listed.

I have decided to automate my search using PHP and Curl.  This way whenever I remember to check to see if my extension is listed I can just run this page in my browser and it will check the site for me and tell me if I am listed yet.

Here is the code and then I will kind of go through it.

<?php
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://extensions.apple.com");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
// grab URL
$result = curl_exec($ch);
$findme = 'puni';
$pos = strpos($result, $findme);

if ($pos === false)
{
echo "The string '$findme' was not found on the safari extensions site.";
}
else
{
echo "The string '$findme' was found in the safari extensions site and exists at position $pos";
}
// close cURL resource, and free up system resources
curl_close($ch);?>

First thing you do is you have to initialize curl into any variable you would like, I use $ch because it seems to be the most common. Next you have to set the headers. There are numerous headers you can set, but you must make sure to set “CURLOPT_RETURNTRANSFER, TRUE”. Basically TRUE means you will return the webpage as a string, instead of outputing the result directly to the browser. You can read more about the option headers here.

After you set the headers you run curl_exec($ch) to actually process the data and return the value as a string into the $result variable. One you do this you set the string you are looking to find and use strpos to find your string nested inside the data from the site.

Now since I am searching for the word puni, since my extension is called puni.co, I am fairly sure no other extensions are going to have this name. If they do I would get a false positive. In the case that I ever get a success and puni is found but it was not my extension, then I will do some simple modification to search for something more explicit.

If strpos does not find the nested string it will return false. So all you need to do is check for false and if it is not false then you have a success, and print out your success message.

If really was serious and wanted to know the exact day my extension was listed I could setup this script to email me and setup a cron job to run every day. Since I am not too worried about when I get listed I am fine just running the script when I think about it.

This way I only have to visit their site once I have a fairly good change that my amazing extension (I am a bit partial) is listed.

Jason Michels on Quora

Posted on : 31-03-2011 | By : TheBizzTech | In : Uncategorized

5

My profile on Quora

Jason Michels

WordPress iPhone App

Posted on : 23-03-2011 | By : TheBizzTech | In : iPhone, wordpress

Tags: ,

5

This is the first post from the WordPress iPhone app I have running on my iPhone 4. Unfortunately, I do not have any cell coverage on AT&T where I am located so I am running off a Verizon Mifi card, but that is another story.

So far I like this app. It was easy to login to my self hosted site, once I enabled remote posting in the settings. I have access to enough features such as adding posts and new categories. It is not the best choice for long posts but it works for a quickie like this one.

Safari Extensions – Puni.co URL Redirection

Posted on : 23-03-2011 | By : TheBizzTech | In : Mac OS, Puni URL Redirection, Safari, Safari Extensions

Tags: , , ,

12

For anyone interested in URL redirection services and Safari Extensions, here is a service offered by TheBizzTech LLC.  We have made a Safari Extension that uses the free puni.co url redirection services.  Visit http://safari.puni.co to download the extension.

It is really simple to use.  Install the extension, this will put a button next to your URL box, that says Puni.  Go to any page you would like and click the “Puni” button.  This will take the URL of the page you are on and give you a nice “puni” URL to use on all of your social networking sites such as Twitter, Facebook, and it is great for SMS text messages.

Here is a good example of the power of this safari extension.  Lets say you want to share a link to a product on Amazon.

Here is the original URL to a product:  http://www.amazon.com/gp/product/B001AVCFK6/ref=s9_hps_bw_fi2?pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-4&pf_rd_r=1VC3996Q585W62FEGRWD&pf_rd_t=101&pf_rd_p=1288871882&pf_rd_i=193640011

Here is the puni.co URL using the website or safari extension: http://puni.co/156

Here is a quick little YouTube video we threw together.

Enjoy, and best of all it is free to use!

Welcome to TheBizzTech.com

Posted on : 23-03-2011 | By : TheBizzTech | In : Uncategorized

2

Welcome to TheBizzTech LLC official website.  I am one of the three co-founders of the company and will be using this site mostly to share some of my software development experiences.  Our company focuses mostly on building our own software projects, such as http://puni.co and, our current project under development http://getbrill.com.  We also provide the occasional web development service to clients that are usually referred to us.

Starting off the main focus of my postings will be on Ruby on Rails, PayPal, PHP, and Jquery.  Let me know if there is anything specific you would like to see.

Enjoy the site, I hope you learn something, and I am sure I will learn much along the way.

Thank You,
Jason Michels
CEO of TheBizzTech LLC