Saturday, December 25, 2010

Special Brands articles about "Programming" #2010

Programming Hands

In 2010 I was less focussed on programming articles on the blog than previous years, still I have managed to create some interesting articles with code in 2010. This is an overview of the activity:

Having some fun today with QR codes, JavaScript and the Google Analytics URL ...

The only questions that are asked in the Daily Scrum, aka Stand-Up, are: What...

UPDATE: GMail has introduced my number 3. YEAH! (Gmail introduces Priority In...

I like YouTube, and often subscribe to new channels and unsubscribe after a w...

Since I started working for my company I’ve been exposed to PCI DSS (Pa...

I don’t understand why url expansion after url shortening is such an is...

VeriSign – Personal Identity Portal is a OpenID provider with multiple ...

Image source D'Arcy Norman

Labels: , , , , , , , , , , , , , , , , , , ,

Friday, October 17, 2008

Figuring out PHP DOMDocument and XSLTProcessor #php

Although I calculate the period I've been programming in decades, I am a relative PHP newbie. I'm testing and playing with PHP and writing distributed services, yet it's sometimes the simple knowledge that I'm missing. (How does this Object perform the function that I want.) So I've been playing with the XML Classes in PHP and modified so code from PHP + Twitter + Google Calendar + SMS
. The article is quite interesting, and I discovered the Zend Framework, which makes my life much easier. :)

<?php
// Define credentials for the Twitter account
define('TWITTER_CREDENTIALS', 'USERNAME:PASSWORD');

// Set up CURL with the Twitter URL and some options
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://twitter.com/statuses/friends_timeline.rss');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// Twitter uses HTTP authentication, so tell CURL to send our Twitter account de
tails
curl_setopt($ch, CURLOPT_USERPWD, TWITTER_CREDENTIALS);


// Execute the curl process and then close
$data = curl_exec($ch);
curl_close($ch);


// MY CHANGES START HERE:

// Load XML
$dom = new DOMDocument();
$dom->loadXML(print_r($data, true));

// Load XSL:
$filename = "rss.xsl"; // You can find an rss.xsl file lots of places.
$domxsl = new DOMDocument();
$domxsl->load($filename);
$xsltp = new XSLTProcessor();
$xsltp->importStylesheet($domxsl);

// Apply XSL to XML
$result = $xsltp->transformToXML($dom);

// Output XSL Transformed XML
print ($result);
?>

Technorati technorati tags: , , , ,

Labels: