WebEX API PHP SDK

WebEx PHP SDK

Are you a PHP developer looking to do WebEx API Integration for things like:

  • Getting WebEx meeting information
  • Retrieving a list of WebEx Event attendees
  • Creating new Meeting and Event attendees

Well, good news – there is now a WebEx PHP SDK (really – just a class with a set of wrapper methods) that makes interacting with the WebEx API Easy.Continue Reading

Intuit QuickBase Website

Since December of 2007, I have had the privilege of being the webmaster of the Intuit QuickBase web marketing website.

What is QuickBase?

Simply put, QuickBase is an online database that business users can use for building and running web-based applications. Intuit QuickBase HeroUses for the types of applications QuickBase customers might create are for project management, sales management, and order tracking.

QuickBase is used by over 50 of the Fortune 100 and has hundreds of thousands of users. Because it is owned and operated by Intuit (makers of TurboTax, Quicken and QuickBooks),  it extremely stable and secure.

My Job at QuickBase as the Webmaster

  • Drive the overall execution of marketing’s website strategies and drive business results
  • Work to define customer success and drive tangible business results to achieve group goals
  • Support the QuickBase team by acting as a designer/developer, ultimately helping them execute their campaigns, tasks, and events
  • Act as liaison for channeling marketing technical and business requirements to the QuickBase PD team
  • Establish self as a thought leader in QuickBase website integration among QuickBase customers

QuickBase Resources

QuickBase Customers

Technologies Used on the QuickBase Marketing Website

  • XHTML
  • CSS
  • XML
  • PHP
  • Apache
  • Redhat Enterprise Linux
  • Zend Framework
  • MySQL
  • WordPress
  • Drupal
  • WebEx API
  • Engage B2B WSAPI
  • QuickBase
  • Google Search Appliance
  • And much more …

[button text=”Launch QuickBase” url=”http://quickbase.intuit.com/” target=”_blank”]

Want to learn more?

If you’re interested in learning more about the QuickBase website or you have any questions, please feel free to contact me.

Easy Cross-Browser @font-face Solution

So you want to use a custom font on your website and you want it to be search-engine friendly, support multiple browsers (including IE6), and you want to use a pure CSS solution because you’re tired of the work involved with sIFR and cufón. Well, @font-face to the rescue.

Convert Your Fonts:

Different browsers require different types of fonts. For example, Internet Explorer requires .EOT and other browsers will require .SVG, .TTF, or .OTF font formats.

Chances are, you probably have the .TTF or .OTF version already installed on your machine. Not a problem, there is an awesome website that will:

  • Convert your fonts to all of the required formats
  • Allow you to make your font file web-only so that people can’t steal your font and install in on their machine
  • Strip out any un-used characters to reduce the file size of the font
  • Automatically generate the fonts and the CSS for you to use the fonts

Here’s the website that can do it all:

http://www.fontsquirrel.com/fontface/generator

How to use @font-face:

@font-face lets you associate a font-family name of your choosing with imported fonts. You can also specify multiple versions of the same font file which you will need to do in order to support the various browsers.

@font-face {
   font-family: 'FSAlbert';
   src: url('fonts/fs_albert-webfont.eot');
   src: local('*'), url('fonts/fs_albert-webfont.ttf') format('truetype'),
      url('fonts/fs_albert-webfont.svg#webfontHPkZa0j3') format('svg');
}

h1 {
   font-family: 'FSAlbert';
}

Notice that I’ve put in an asterisk in the local param. Assuming the user does not have a font installed called *, this will force the browser to use the remote font files for the designated font name.

Inroduction to Writing PHP Command-Line (CLI) Scripts

In this tutorial, I will show you how to get started with writing command-line interface (CLI) scripts using PHP. Here are a few reasons why you might want to write a CLI application in PHP:

  • You want to write a tool for admin-ing your server, but you’re more comfortable using PHP
  • You don’t need to output any content to a public-facing web page

The Basics

First, I’ll assume you’ve already got PHP setup on your web server and that you either know the path to the php executable or you’ve already added to your system’s PATH (you can test this by passing php –v to the CLI). If not, see this link.

When executing a command-line script, there are essentially three pieces to the command that is entered into the prompt.

Example:

> /path/to/php script.php arguments

/path/to/php: the path to your PHP executable.
script.php: the name of the PHP script you are executing
arguments: any commands, options, flags, or arguments you’ll be passing to the script

If you aren’t passing anything arguments to the script in the command-line, then what you see above is basically all you need to know to execute a script at the command-line. You’ve told the CLI what the interpreter will be for the command (/path/to/php) and the name of script to execute. Once you hit enter, the result should print directly to the screen.

Most users, however, will want to do more than just execute a standalone script with no external information passed to the script. For this, you’ll need to know how to read arguments passed to the script.

Reading Arguments in PHP from a CLI

PHP provides two important predefined variables that will make CLI scripting in PHP possible: $argv and $argc.

$argc

$argc [$argc on php.net] is the easiest to get. It is simply the number of arguments passed to the script and it can be useful when determining whether or not a user entered a parameter.

*Note: The filename of the script is always passed as an argument to the script so the $argc count will always have a minimum value of 1.

Example 1

<?php
   var_dump($argc);
?>

Example 2:

<?php
//Check to see if there were params passed to the script
if ( $argc > 1 ) {
  //do stuff here
}
?>

$argv

$argv [$argv on php.net] is the work horse of PHP CLI scripting and this is where you’ll be spending a lot of your time when writing interactive scripts. $argv is an array of arguments passed to the script.

Let’s look at some examples:

>  /path/to/php script.php arg1 arg2

Output:

array(2) {
  [0]=>
    string(10) "script.php"
  [1]=>
   string(4) "arg1"
  [2]=>
   string(4) "arg2"
}

Notice that the first argument is always the name of the script.php that was executed.

Setting PHP ini variables in a CLI script

Example:

#!/usr/bin/php –d memory_limit=512M

<?php
  print "memory_limit=".ini_get("memory_limit")."\n";
  var_dump($argv);
?>

There’s a lot thrown into this one, but let’s start at the beginning. In the linux/unix world, whenever the first two characters are “#!” (pound shebang), the system recognizes these as interpreter directives that alerts the system that this file is indeed a script and it should be interpreted by the path to executable after the directives (in our case: /usr/bin/php). Read more about the shebang.

On the same line, we’re passing the –d flag (which tells php we’re about set an INI config) and then of course, we’re setting the memory_limit to 512 Mb.

When the script is executed, it will read this line first and then pass the rest of the file to the interpreter.

Output:

memory_limit=512M
array(1) {
  [0]=>
  string(12) "./script.php"
}

How to accept user input in a PHP CLI script:

Here’s an example of how to write an interactive script that allows the user executing the script to enter in input during script execution.

Example:

<?php
  echo "Are you sure you want to do this?  Type 'yes' to continue: ";

  $handle = fopen ("php://stdin","r");
  $line = fgets($handle);

  if(trim($line) != 'yes'){
     echo "ABORTING!\n";
     exit;
  }

  echo "\n";
  echo "Thank you, continuing...\n";
?>

To read the contents of input, you’ll need to use the php://stdin input stream.

In conclusion, if you’re beyond this beginner tutorial, I’d start by reading php.net’s command-line features page. There are a lot more examples of how to do more involved things like looping through $argv and parsing the arguments to make the script perform as desired.

PHP SDK for QuickBase API

QuickBase PHP SDK

During my time at Intuit, I have been a strong advocate of using and giving back to the open source community and one of the projects I’ve had the privilege of working on is the QuickBase PHP SDK project at code.intuit.com.

This SDK is in heavy use on the QuickBase web-marketing website. We use it primarily to integrate many of the back-end systems we’ve created for tracking and customer management with the front-end where our website visitors interact with us.

Examples of why you might need the QuickBase PHP SDK:

  • You’re doing PHP development and QuickBase API integration
  • You need to complete your QuickBase project FAST due to the demands of your team
  • The QuickBase Javascript SDK is great, but can only be used on the quickbase.com domain due to XSS (cross-site scripting) security limitations

Examples of how you might use the QuickBase PHP SDK:

  • You want to create web forms that populate data dynamically into various QuickBase
  • You need the read data from a QuickBase and do “stuff” with it (caching, display it, move it around, manipulate it, etc)
  • You need to update information in a QuickBase in nightly batches through the use of custom cron scripts

Do any of the examples above sound familiar?

For the app-y things we like to build, QuickBase and its robust API work great.

We use QuickBase as our database work horse for a lot of what we do. I won’t pretend it is a direct replacement for MySQL or any other enterprise transaction database – but it’s a great solution for a group like us who have a totally custom web application that doesn’t necessarily want/need the overhead of a self-managed SQL-based database. For the app-y things we like to build, QuickBase and its robust API work great.

On the QuickBase website, we have over five QuickBase’s acting as mini-CMS’s, populating areas of our site such as our Customers section and Recent News.

How to download the QuickBase SDK

In the past, I made the SDK available immediately available through my blog – however, that is changing because I need people to contribute to the project.

The only way I’m going to make this SDK better is by getting feedback and having folks help knock out the bugs.

The first thing you should do is because a project member:

[button text=”Join the Project” url=”http://code.intuit.com/sf/projects/qb_php_sdk” target=”_blank”]

Or you can just check out the sdk with Subversion like so:

svn checkout https://code.intuit.com/svn/repos/quickbase-php-sdk

Helpful Resources

QuickBase Questions, FAQ’s, and API Support

If you have a question about QuickBase, the use of the api in particular, please ask in the comments of this post. I will update this blog post to include your question and my answer so that others who come across my site can see it. Many of you have been emailing me GREAT questions that I would love to share with the rest of the QuickBase community.

Any questions about QuickBase are open game, but my speciality is with the QuickBase API. If I don’t know the answer, I’ll find it and/or get you in touch with someone who can.

This is not an official alternative to contacting our support at http://quickbase.intuit.com/support/. You should still contact our support team if you have any urgent or business-critical inquiries.

1. How can I create a web form to let a user edit and add records in QuickBase?

I have a custom form, created with the QuickBase custom form wizard, which anyone can use to add a new record to my table in my QuickBase application.

Ideally, though, I would like users to be able to edit existing records with the form. Unfortunately, I have only found commands that point the form to edit existing records. Is there anyway this form can edit the form if some of the fields match? E.g. The name field in the existing record is ‘Joey’. When the user enters ‘Joey’ into the form, it would automatically point the edited record to edit the entire record that includes ‘Joey’ in the name field.

Answer

In order to do this, you would need to invoke either javascript or process the form via a backend script (like PHP) to handle the logic of whether or not to do an add_record or an edit_record.

I’d recommend you host the form yourself on your company’s website (if you aren’t already) and use the api for processing the form. Doing this gives you more flexibility in what you can do with the data that is submitted and what records are affected.

QuickBase PHP API Examples

i’ve had a few requests for examples of how to use the quickbase php api wrapper. so here goes:

setup the quickbase object with login info

include the library and setup the object by passing in username, password, true/false (xml/http), and dbID of the db/table you’ll be transacting with.

include_once('../includes/qb.php');
$quickbase = new QuickBase('username','password', true, 'dbID');

do a quickbase query

here, we setup a query to return field 3 where (field id 15 is equal to somevalue).

$queries = array(
      array(
        'fid' => '15',
        'ev'  => 'ex',
        'cri' => 'somevalue')
       );

$results = $quickbase->do_query($queries, '', '', '3');

adding a record to a quickbase

this one is super easy. create an associative array with field id’s and values and then use the add_record method.

$fields = array(
      array(
        'fid' => '1',
        'value' => 'some value'),
      array(
        'fid' => '2',
        'value' => 'some value'),
      array(
        'fid' => '3',
'value'=>'some value')
              );
$quickbase->add_record($fields);

edit a quickbase record

almost identical to add_record, setup the array and use the edit_record method.

$fields = array(
      array(
        'fid' => '1',
        'value' => 'some value'),
      array(
        'fid' => '2',
        'value' => 'some value'),
      array(
        'fid' => '3',
'value'=>'some value')
              );
$quickbase->edit_record($fields);

do a quickbase query

here, we setup a query to return field 3 where (field id 15 is equal to somevalue).

$queries = array(
      array(
        'fid' => '15',
        'ev'  => 'ex',
        'cri' => 'somevalue')
       );

$results = $quickbase->do_query($queries, '', '', '5');

WebEx API PHP Wrapper

I did some work this week with integrating webex into the quickbase website. As a result, i ended up putting together a wrapper for the WebEx XML API in order to speed up development time.

If you’re going to be using webex with PHP, check it out.

It doesn’t have full support for all API methods (yet), but if there’s enough interest, perhaps I’ll keep building on it in my “spare” (ha) time.