<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:thr='http://purl.org/syndication/thread/1.0' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-3679924792075541139</atom:id><lastBuildDate>Mon, 26 Jul 2010 07:28:08 +0000</lastBuildDate><title>webmauk</title><description></description><link>http://blog.webma.co.uk/</link><managingEditor>noreply@blogger.com (James Lucas)</managingEditor><generator>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-3679924792075541139.post-4418431743544053833</guid><pubDate>Mon, 03 Nov 2008 15:50:00 +0000</pubDate><atom:updated>2008-11-04T09:51:50.843Z</atom:updated><title>Introduction to Zend Framework</title><description>Zend Framework is an incredibly useful library for PHP development.&lt;br /&gt;&lt;br /&gt;Its homepage can be found at &lt;a href="http://framework.zend.com"&gt;http://framework.zend.com&lt;/a&gt;.  At the time of writing version 1.6 was available and 1.7 was on preview release.&lt;br /&gt;&lt;br /&gt;It particularly simplifies the creation of web 2.0 applications and the integration of external ones such as Flickr, Amazon and Google.&lt;br /&gt;&lt;br /&gt;All code within Zend Framework is object-oriented and written in PHP 5.&lt;br /&gt;&lt;br /&gt;Zend Framework is based upon a &lt;a href="http://en.wikipedia.org/wiki/Model-view-controller"&gt;MVC&lt;/a&gt; implementation.&lt;br /&gt;&lt;br /&gt;Many of the libraries can also be used individually, for example if you were looking to integrate a book search within your website the following example shows how simple it is to use:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;$query = new Zend_Service_Amazon_Query('AMAZON_API_KEY');&lt;br /&gt;$query-&gt;category('Books')-&gt;Keywords('PHP');&lt;br /&gt;$results = $query-&gt;search();&lt;br /&gt;foreach ($results as $result) {&lt;br /&gt;    echo $result-&gt;Title . '&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Alternatively you could use it to find photos on Flickr that match a keyword:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;$flickr = new Zend_Service_Flickr('MY_API_KEY');&lt;br /&gt;&lt;br /&gt;$results = $flickr-&gt;tagSearch("php");&lt;br /&gt;&lt;br /&gt;foreach ($results as $result) {&lt;br /&gt;    echo $result-&gt;title . '&amp;lt;br /&amp;gt;';&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;There is a wide range of functionality available within the framework and I will delve further into these in later posts, they include:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Authorisation&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Access Control&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Captcha Generation&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Database Integration&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Data Validation&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Email Creation&lt;/li&gt;&lt;br /&gt;&lt;li&gt;PDF Generation&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Webservices Integration&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3679924792075541139-4418431743544053833?l=blog.webma.co.uk' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.webma.co.uk/2008/08/introduction-to-zend-framework.html</link><author>noreply@blogger.com (James Lucas)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-3679924792075541139.post-4858877418371998510</guid><pubDate>Mon, 25 Aug 2008 13:00:00 +0000</pubDate><atom:updated>2008-08-25T14:00:00.301+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>tutorial</category><category domain='http://www.blogger.com/atom/ns#'>epp</category><category domain='http://www.blogger.com/atom/ns#'>php</category><category domain='http://www.blogger.com/atom/ns#'>nominet</category><title>Creating Nominet EPP messages using Smarty</title><description>As mentioned in a previous post on &lt;a href="http://blog.webma.co.uk/2008/08/conecting-to-nominet-epp-with-php.html"&gt;Connecting to Nominet EPP with PHP&lt;/a&gt;, the &lt;a href="http://www.smarty.net"&gt;Smarty&lt;/a&gt; templating system is an easy to use way to create EPP messages without having to resort to complicated XML generation. &lt;br /&gt;&lt;br /&gt;For information on how to get started with Smarty, see my &lt;a href="http://blog.webma.co.uk/2008/08/introduction-to-smarty.html"&gt;Introduction To Smarty&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;EPP requests are standard XML documents with a few variables that change on each request.&lt;br /&gt;&lt;br /&gt;For example, to query information related to a domain name the &lt;a href="http://www.nic.uk/registrars/systems/epp/info/"&gt;info&lt;/a&gt; command is used:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&amp;gt;&lt;br /&gt;    &amp;lt;epp xmlns="urn:ietf:params:xml:ns:epp-1.0"&lt;br /&gt;         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br /&gt;         xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0&lt;br /&gt;         epp-1.0.xsd"&amp;gt;&lt;br /&gt;      &amp;lt;command&amp;gt;&lt;br /&gt;        &amp;lt;info&amp;gt;&lt;br /&gt;          &amp;lt;domain:info&lt;br /&gt;           xmlns:domain="http://www.nominet.org.uk/epp/xml/nom-domain-1.0"&lt;br /&gt;           xsi:schemaLocation="http://www.nominet.org.uk/epp/xml/nom-domain-1.0&lt;br /&gt;           nom-domain-1.0.xsd"&amp;gt;&lt;br /&gt;            &amp;lt;domain:name&amp;gt;webma.co.uk&amp;lt;/domain:name&amp;gt;&lt;br /&gt;         &amp;lt;/domain:info&amp;gt;&lt;br /&gt;       &amp;lt;/info&amp;gt;&lt;br /&gt;       &amp;lt;clTRID&amp;gt;EXAMPLE-12345&amp;lt;/clTRID&amp;gt;&lt;br /&gt;     &amp;lt;/command&amp;gt;&lt;br /&gt;   &amp;lt;/epp&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The only two elements that change in this XML from one request to the next are the domain name and the clTRID which is the client transaction id, therefore a smarty template of the following:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&amp;gt;&lt;br /&gt;    &amp;lt;epp xmlns="urn:ietf:params:xml:ns:epp-1.0"&lt;br /&gt;         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br /&gt;         xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0&lt;br /&gt;         epp-1.0.xsd"&amp;gt;&lt;br /&gt;      &amp;lt;command&amp;gt;&lt;br /&gt;        &amp;lt;info&amp;gt;&lt;br /&gt;          &amp;lt;domain:info&lt;br /&gt;           xmlns:domain="http://www.nominet.org.uk/epp/xml/nom-domain-1.0"&lt;br /&gt;           xsi:schemaLocation="http://www.nominet.org.uk/epp/xml/nom-domain-1.0&lt;br /&gt;           nom-domain-1.0.xsd"&amp;gt;&lt;br /&gt;            &amp;lt;domain:name&amp;gt;{$domain_name}&amp;lt;/domain:name&amp;gt;&lt;br /&gt;         &amp;lt;/domain:info&amp;gt;&lt;br /&gt;       &amp;lt;/info&amp;gt;&lt;br /&gt;       &amp;lt;clTRID&amp;gt;{$transaction_id}&amp;lt;/clTRID&amp;gt;&lt;br /&gt;     &amp;lt;/command&amp;gt;&lt;br /&gt;   &amp;lt;/epp&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;would fit the purpose, assuming this is saved in a file called info.tpl, to get the correct XML for an info request use the following PHP code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;$smarty-&gt;assign('domain_name','webma.co.uk');&lt;br /&gt;$smarty-&gt;assign('transaction_id','TAG_NAME-123');&lt;br /&gt;$xml = $smarty-&gt;fetch('info.tpl');&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This can be repeated for any EPP request needed very simply.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3679924792075541139-4858877418371998510?l=blog.webma.co.uk' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.webma.co.uk/2008/08/creating-nominet-epp-messages-using.html</link><author>noreply@blogger.com (James Lucas)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-3679924792075541139.post-44053763779686690</guid><pubDate>Sun, 24 Aug 2008 14:47:00 +0000</pubDate><atom:updated>2008-08-24T15:47:00.249+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>hello world</category><category domain='http://www.blogger.com/atom/ns#'>tutorial</category><category domain='http://www.blogger.com/atom/ns#'>php</category><category domain='http://www.blogger.com/atom/ns#'>smarty</category><title>Introduction to Smarty</title><description>Smarty is a template engine for PHP, and one that is very easy to use at that.&lt;br /&gt;&lt;br /&gt;It can be downloaded from &lt;a href="http://www.smarty.net/download.php"&gt;http://www.smarty.net/download.php&lt;/a&gt; or is included in some Linux distributions.&lt;br /&gt;&lt;br /&gt;Rather than repeat them all here, there are easy to use installation instructions on the Smarty website at &lt;a href="http://www.smarty.net/quick_start.php"&gt;http://www.smarty.net/quick_start.php&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;There are two ways primary ways to assign variables to Smarty, directly as a variable, e.g. a string or an integer which can be down via the following:&lt;br /&gt;&lt;br /&gt;//assign an integer of 1 to the variable 'var1'&lt;br /&gt;$smarty-&gt;assign('var1',1);&lt;br /&gt;&lt;br /&gt;//assign a string 'test' to the variable 'var2'&lt;br /&gt;$smarty-&gt;assign('var2','test');&lt;br /&gt;&lt;br /&gt;//assign an array to the variable 'var3'&lt;br /&gt;$smarty-&gt;assign('var3',array(1,2,3,4));&lt;br /&gt;&lt;br /&gt;You can also pass an associative array to assign multiple variables at once, e.g:&lt;br /&gt;$smarty-&gt;assign(array('var1' =&gt; 1,'var2' =&gt; 'test', 'var3' =&gt; array (1,2,3,4)));&lt;br /&gt;This will have the same effect as the 3 lines above.&lt;br /&gt;&lt;br /&gt;In the Smarty template, to use the variables, all you would need to do is the following:&lt;br /&gt;{$var1}, this will output the value of $var1 wherever you write this.&lt;br /&gt;&lt;br /&gt;The second way is to assign by reference, you would use this if you are assigning an object to the template, for example given a class called HelloClass that returns "Hello World" when you call its hello() function, you can assign it to smarty with:&lt;br /&gt;$smarty-&gt;assign_by_ref('hello_class',new HelloClass);&lt;br /&gt;and in the template you would call it with {$hello_class-&gt;hello()}&lt;br /&gt;&lt;br /&gt;To display a template, the code is as follows:&lt;br /&gt;$smarty-&gt;display('template.tpl');&lt;br /&gt;&lt;br /&gt;There is much much more to Smarty, you can find its full manual at &lt;a href="http://www.smarty.net/manual/en/"&gt;http://www.smarty.net/manual/en/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3679924792075541139-44053763779686690?l=blog.webma.co.uk' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.webma.co.uk/2008/08/introduction-to-smarty.html</link><author>noreply@blogger.com (James Lucas)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-3679924792075541139.post-3435734993212677260</guid><pubDate>Sat, 23 Aug 2008 14:00:00 +0000</pubDate><atom:updated>2008-08-23T21:09:38.395+01:00</atom:updated><title>Connecting to Nominet EPP with PHP</title><description>&lt;a href="http://en.wikipedia.org/wiki/Extensible_Provisioning_Protocol"&gt;EPP&lt;/a&gt; stands for Extensible Provisioning Protocol, this is the method that a large number of domain registries use to communicate.&lt;br /&gt;&lt;br /&gt;This is a basic example of how to connect to an EPP server using a basic script supplied by &lt;a href="https://www.centralnic.com/"&gt;CentralNic&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The script, Net_EPP_Client can be downloaded from &lt;a href="http://labs.centralnic.com/Net_EPP_Client.php"&gt;CentralNic Labs&lt;/a&gt; and can be installed using &lt;a href="http://pear.php.net"&gt;PEAR&lt;/a&gt; or manually by copying into the relevant directory.&lt;br /&gt;&lt;br /&gt;For the examples in the post, we will be logging into the &lt;a href="http://www.nominet.org.uk"&gt;Nominet&lt;/a&gt; EPP server.&lt;br /&gt;&lt;br /&gt;EPP clients connect to a server, login and then send the commands that wish to make.  An example of connecting is as follows:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;require('Net/EPP/Client.php');&lt;br /&gt;&lt;br /&gt;$client = new Net_EPP_Client;&lt;br /&gt;$host = 'epp.nominet.org.uk';&lt;br /&gt;$port = 700;&lt;br /&gt;$timeout = 10;&lt;br /&gt;$ssl = true;&lt;br /&gt;&lt;br /&gt;$greeting = $client-&gt;connect($host, $port, $timeout, $ssl);&lt;br /&gt;&lt;br /&gt;echo $greeting;&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;Which will output&lt;pre&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&amp;gt;&lt;br /&gt;&amp;lt;epp xmlns="urn:ietf:params:xml:ns:epp-1.0"&lt;br /&gt;     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br /&gt;     xsi:schemaLocation="http://www.nominet.org.uk/epp/xml/epp-1.0 epp-1.0.xsd"&amp;gt;&lt;br /&gt;  &amp;lt;greeting&amp;gt;&lt;br /&gt;    &amp;lt;svID&amp;gt;Nominet EPP server epp.nominet.org.uk&amp;lt;/svID&amp;gt;&lt;br /&gt;    &amp;lt;svDate&amp;gt;2008-08-23T16:24:51Z&amp;lt;/svDate&amp;gt;&lt;br /&gt;    &amp;lt;svcMenu&amp;gt;&lt;br /&gt;      &amp;lt;version&amp;gt;1.0&amp;lt;/version&amp;gt;&lt;br /&gt;      &amp;lt;lang&amp;gt;en&amp;lt;/lang&amp;gt;&lt;br /&gt;      &amp;lt;objURI&amp;gt;http://www.nominet.org.uk/epp/xml/nom-account-1.0&amp;lt;/objURI&amp;gt;&lt;br /&gt;      &amp;lt;objURI&amp;gt;http://www.nominet.org.uk/epp/xml/nom-domain-1.0&amp;lt;/objURI&amp;gt;&lt;br /&gt;      &amp;lt;objURI&amp;gt;http://www.nominet.org.uk/epp/xml/nom-contact-1.0&amp;lt;/objURI&amp;gt;&lt;br /&gt;      &amp;lt;objURI&amp;gt;http://www.nominet.org.uk/epp/xml/nom-ns-1.0&amp;lt;/objURI&amp;gt;&lt;br /&gt;    &amp;lt;/svcMenu&amp;gt;&lt;br /&gt;    &amp;lt;dcp&amp;gt;&lt;br /&gt;      &amp;lt;access&amp;gt;&amp;lt;all/&amp;gt;&amp;lt;/access&amp;gt;&lt;br /&gt;      &amp;lt;statement&amp;gt;&lt;br /&gt;        &amp;lt;purpose&amp;gt;&amp;lt;admin/&amp;gt;&amp;lt;prov/&amp;gt;&amp;lt;/purpose&amp;gt;&lt;br /&gt;        &amp;lt;recipient&amp;gt;&amp;lt;ours/&amp;gt;&amp;lt;/recipient&amp;gt;&lt;br /&gt;        &amp;lt;retention&amp;gt;&amp;lt;indefinite/&amp;gt;&amp;lt;/retention&amp;gt;&lt;br /&gt;      &amp;lt;/statement&amp;gt;&lt;br /&gt;    &amp;lt;/dcp&amp;gt;&lt;br /&gt;  &amp;lt;/greeting&amp;gt;&lt;br /&gt;&amp;lt;/epp&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This shows that the connection is correctly opened and you are now able to login by sending back the following reply:&lt;pre&gt;&lt;br /&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;br /&gt;  &amp;lt;epp xmlns="urn:ietf:params:xml:ns:epp-1.0"&lt;br /&gt;       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br /&gt;       xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd"&amp;gt;&lt;br /&gt;    &amp;lt;command&amp;gt;&lt;br /&gt;      &amp;lt;login&amp;gt;&lt;br /&gt;        &amp;lt;clID&amp;gt;TAG_NAME&amp;lt;/clID&amp;gt;&lt;br /&gt;        &amp;lt;pw&amp;gt;password&amp;lt;/pw&amp;gt;&lt;br /&gt;        &amp;lt;options&amp;gt;&lt;br /&gt;          &amp;lt;version&amp;gt;1.0&amp;lt;/version&amp;gt;&lt;br /&gt;          &amp;lt;lang&amp;gt;en&amp;lt;/lang&amp;gt;&lt;br /&gt;        &amp;lt;/options&amp;gt;&lt;br /&gt;        &amp;lt;svcs&amp;gt;&lt;br /&gt;           &amp;lt;objURI&amp;gt;http://www.nominet.org.uk/epp/xml/nom-account-1.0&amp;lt;/objURI&amp;gt;&lt;br /&gt;           &amp;lt;objURI&amp;gt;http://www.nominet.org.uk/epp/xml/nom-domain-1.0&amp;lt;/objURI&amp;gt;&lt;br /&gt;           &amp;lt;objURI&amp;gt;http://www.nominet.org.uk/epp/xml/nom-contact-1.0&amp;lt;/objURI&amp;gt;&lt;br /&gt;           &amp;lt;objURI&amp;gt;http://www.nominet.org.uk/epp/xml/nom-ns-1.0&amp;lt;/objURI&amp;gt;&lt;br /&gt;        &amp;lt;/svcs&amp;gt;&lt;br /&gt;      &amp;lt;/login&amp;gt;&lt;br /&gt;      &amp;lt;clTRID&amp;gt;your_transaction_id&amp;lt;/clTRID&amp;gt;&lt;br /&gt;    &amp;lt;/command&amp;gt;&lt;br /&gt;  &amp;lt;/epp&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;I find that an easy way to manage creating EPP XML requests is by using the &lt;a href="http://www.smarty.net"&gt;Smarty&lt;/a&gt; templating system, more on that in a later post.&lt;br /&gt;&lt;br /&gt;You should then receive a reply indicating your login was successful:&lt;br /&gt;&lt;pre&gt;&amp;lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&amp;gt;&lt;br /&gt;&amp;lt;epp xmlns="urn:ietf:params:xml:ns:epp-1.0"&lt;br /&gt;      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&lt;br /&gt;      xsi:schemaLocation="http://www.nominet.org.uk/epp/xml/epp-1.0 epp-1.0.xsd"&amp;gt;&lt;br /&gt;  &amp;lt;response&amp;gt;&lt;br /&gt;    &amp;lt;result code="1000"&amp;gt;&lt;br /&gt;      &amp;lt;msg&amp;gt;&lt;br /&gt;        Command completed successfully&lt;br /&gt;      &amp;lt;/msg&amp;gt;&lt;br /&gt;    &amp;lt;/result&amp;gt;&lt;br /&gt;    &amp;lt;trID&amp;gt;&lt;br /&gt;      &amp;lt;clTRID&amp;gt;EPP-your_transaction_id&amp;lt;/clTRID&amp;gt;&lt;br /&gt;      &amp;lt;svTRID&amp;gt;12345678&amp;lt;/svTRID&amp;gt;&lt;br /&gt;    &amp;lt;/trID&amp;gt;&lt;br /&gt;  &amp;lt;/response&amp;gt;&lt;br /&gt;&amp;lt;/epp&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;From there you can go on to perform the actions you require, more information on using Nominet's EPP service can be found at &lt;a href="http://www.nic.uk/registrars/systems/epp/"&gt;http://www.nic.uk/registrars/systems/epp/&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3679924792075541139-3435734993212677260?l=blog.webma.co.uk' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.webma.co.uk/2008/08/connecting-to-nominet-epp-with-php.html</link><author>noreply@blogger.com (James Lucas)</author><thr:total>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-3679924792075541139.post-3296775047739776271</guid><pubDate>Fri, 22 Aug 2008 13:39:00 +0000</pubDate><atom:updated>2008-08-23T18:12:44.672+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>xml</category><category domain='http://www.blogger.com/atom/ns#'>php5</category><category domain='http://www.blogger.com/atom/ns#'>php</category><category domain='http://www.blogger.com/atom/ns#'>create xml</category><category domain='http://www.blogger.com/atom/ns#'>simplexml</category><title>Parsing XML using SimpleXML and PHP</title><description>One of the very useful things about the &lt;a href="http://www.php.net/simplexml"&gt;SimpleXML&lt;/a&gt; extension in &lt;a href="http://www.php.net"&gt;PHP&lt;/a&gt; is parsing XML data very simply and easily, for example, using the XML file created in a previous &lt;a href="http://blog.webma.co.uk/2008/08/creating-xml-with-simplexml-and-php.html"&gt;post&lt;/a&gt; which looks as follows:&lt;br /&gt;&lt;pre&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;br /&gt;&amp;lt;messages&amp;gt;&lt;br /&gt;        &amp;lt;message&amp;gt;&lt;br /&gt;                &amp;lt;subject&amp;gt;Hello&amp;lt;/subject&amp;gt;&lt;br /&gt;                &amp;lt;from&amp;gt;user@example.com&amp;lt;/from&amp;gt;&lt;br /&gt;                &amp;lt;to&amp;gt;user2@example.com&amp;lt;/to&amp;gt;&lt;br /&gt;                &amp;lt;body&amp;gt;Hello World&amp;lt;/body&amp;gt;&lt;br /&gt;        &amp;lt;/message&amp;gt;&lt;br /&gt;        &amp;lt;message&amp;gt;&lt;br /&gt;                &amp;lt;subject&amp;gt;Hello Again&amp;lt;/subject&amp;gt;&lt;br /&gt;                &amp;lt;from&amp;gt;user@example.com&amp;lt;/from&amp;gt;&lt;br /&gt;                &amp;lt;to&amp;gt;user2@example.com&amp;lt;/to&amp;gt;&lt;br /&gt;                &amp;lt;body&amp;gt;Hello World Take 2&amp;lt;/body&amp;gt;&lt;br /&gt;        &amp;lt;/message&amp;gt;&lt;br /&gt;&amp;lt;/messages&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Assuming the xml is located in a file called test.xml we can loop through the contents with the following code:&lt;br /&gt;&lt;pre&gt;&amp;lt;?php&lt;br /&gt;$xml = simplexml_load_file("test.xml");&lt;br /&gt;&lt;br /&gt;foreach ($xml-&gt;message as $message)&lt;br /&gt;{&lt;br /&gt;    print_r($message);&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;The $xml-&amp;gt;message object is seen as an array so outputs the following:&lt;pre&gt;&lt;br /&gt;SimpleXMLElement Object&lt;br /&gt;(&lt;br /&gt;    [subject] =&gt; Hello&lt;br /&gt;    [from] =&gt; user@example.com&lt;br /&gt;    [to] =&gt; user2@example.com&lt;br /&gt;    [body] =&gt; Hello World&lt;br /&gt;)&lt;br /&gt;SimpleXMLElement Object&lt;br /&gt;(&lt;br /&gt;    [subject] =&gt; Hello Again&lt;br /&gt;    [from] =&gt; user@example.com&lt;br /&gt;    [to] =&gt; user2@example.com&lt;br /&gt;    [body] =&gt; Hello World Take 2&lt;br /&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;It is also very easy to manipulate data within the array, for example to change to to address on the second message:&lt;pre&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;$xml = simplexml_load_file("test.xml");&lt;br /&gt;&lt;br /&gt;//find the second element, (starting from 0)&lt;br /&gt;$xml-&gt;message[1]-&gt;to = "user3@example.com";&lt;br /&gt;&lt;br /&gt;foreach ($xml-&gt;message as $message)&lt;br /&gt;{&lt;br /&gt;    print_r($message);&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;Would output:&lt;pre&gt;&lt;br /&gt;SimpleXMLElement Object&lt;br /&gt;(&lt;br /&gt;    [subject] =&gt; Hello&lt;br /&gt;    [from] =&gt; user@example.com&lt;br /&gt;    [to] =&gt; user2@example.com&lt;br /&gt;    [body] =&gt; Hello World&lt;br /&gt;)&lt;br /&gt;SimpleXMLElement Object&lt;br /&gt;(&lt;br /&gt;    [subject] =&gt; Hello Again&lt;br /&gt;    [from] =&gt; user@example.com&lt;br /&gt;    [to] =&gt; user3@example.com&lt;br /&gt;    [body] =&gt; Hello World Take 2&lt;br /&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3679924792075541139-3296775047739776271?l=blog.webma.co.uk' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.webma.co.uk/2008/08/parsing-xml-using-simplexml-and-php.html</link><author>noreply@blogger.com (James Lucas)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-3679924792075541139.post-7934374529706289550</guid><pubDate>Thu, 21 Aug 2008 12:59:00 +0000</pubDate><atom:updated>2008-08-21T14:48:36.428+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>php</category><category domain='http://www.blogger.com/atom/ns#'>create xml</category><category domain='http://www.blogger.com/atom/ns#'>addchild</category><category domain='http://www.blogger.com/atom/ns#'>simplexml</category><title>Creating XML with SimpleXML and PHP</title><description>Following on from my &lt;a href="http://blog.webma.co.uk/2008/08/introduction-to-simplexml-with-php.html"&gt;Introduction to SimpleXML with PHP&lt;/a&gt;, SimpleXML can also be used to create XML documents.&lt;br /&gt;&lt;br /&gt;The XML example in the previous post:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;br /&gt;&amp;lt;message&amp;gt;&lt;br /&gt; &amp;lt;subject&amp;gt;Hello&amp;lt;/subject&amp;gt;&lt;br /&gt; &amp;lt;from&amp;gt;user@example.com&amp;lt;/from&amp;gt;&lt;br /&gt; &amp;lt;to&amp;gt;user2@example.com&amp;lt;/to&amp;gt;&lt;br /&gt; &amp;lt;body&amp;gt;Hello World&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/message&amp;gt;&lt;br /&gt;&lt;/pre&gt;Can be created with the following code:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;//create SimpleXML object&lt;br /&gt;$xml = simplexml_load_string("&amp;lt;message&amp;gt;&amp;lt;/message&amp;gt;");&lt;br /&gt;&lt;br /&gt;//add subject element&lt;br /&gt;$xml-&gt;addChild('subject','Hello');&lt;br /&gt;&lt;br /&gt;//add from element&lt;br /&gt;$xml-&gt;addChild('from','user@example.com');&lt;br /&gt;&lt;br /&gt;//add to element&lt;br /&gt;$xml-&gt;addChild('to','user2@example.com');&lt;br /&gt;&lt;br /&gt;//add body element&lt;br /&gt;$xml-&gt;addChild('body','Hello World');&lt;br /&gt;&lt;br /&gt;//output XML&lt;br /&gt;echo $xml-&gt;asXML();&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can also add sub elements to elements that you create: for example if your XML files was to have a list of messages:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;$xml = simplexml_load_string("&amp;lt;messages&amp;gt;&amp;lt;/messages&amp;gt;");&lt;br /&gt;&lt;br /&gt;//add child to xml object and return new object for that child&lt;br /&gt;$message1 = $xml-&gt;addChild('message');&lt;br /&gt;$message1-&gt;addChild('subject','Hello');&lt;br /&gt;$message1-&gt;addChild('from','user@example.com');&lt;br /&gt;$message1-&gt;addChild('to','user2@example.com');&lt;br /&gt;$message1-&gt;addChild('body','Hello World');&lt;br /&gt;&lt;br /&gt;//add second child to xml object and return new object for that child&lt;br /&gt;$message2 = $xml-&gt;addChild('message');&lt;br /&gt;$message2-&gt;addChild('subject','Hello Again');&lt;br /&gt;$message2-&gt;addChild('from','user@example.com');&lt;br /&gt;$message2-&gt;addChild('to','user2@example.com');&lt;br /&gt;$message2-&gt;addChild('body','Hello World Take 2');&lt;br /&gt;&lt;br /&gt;//output XML&lt;br /&gt;echo $xml-&gt;asXML();&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;This will output:&lt;pre&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;br /&gt;&amp;lt;messages&amp;gt;&lt;br /&gt;        &amp;lt;message&amp;gt;&lt;br /&gt;                &amp;lt;subject&amp;gt;Hello&amp;lt;/subject&amp;gt;&lt;br /&gt;                &amp;lt;from&amp;gt;user@example.com&amp;lt;/from&amp;gt;&lt;br /&gt;                &amp;lt;to&amp;gt;user2@example.com&amp;lt;/to&amp;gt;&lt;br /&gt;                &amp;lt;body&amp;gt;Hello World&amp;lt;/body&amp;gt;&lt;br /&gt;        &amp;lt;/message&amp;gt;&lt;br /&gt;        &amp;lt;message&amp;gt;&lt;br /&gt;                &amp;lt;subject&amp;gt;Hello Again&amp;lt;/subject&amp;gt;&lt;br /&gt;                &amp;lt;from&amp;gt;user@example.com&amp;lt;/from&amp;gt;&lt;br /&gt;                &amp;lt;to&amp;gt;user2@example.com&amp;lt;/to&amp;gt;&lt;br /&gt;                &amp;lt;body&amp;gt;Hello World Take 2&amp;lt;/body&amp;gt;&lt;br /&gt;        &amp;lt;/message&amp;gt;&lt;br /&gt;&amp;lt;/messages&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3679924792075541139-7934374529706289550?l=blog.webma.co.uk' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.webma.co.uk/2008/08/creating-xml-with-simplexml-and-php.html</link><author>noreply@blogger.com (James Lucas)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-3679924792075541139.post-6488046066346887064</guid><pubDate>Wed, 20 Aug 2008 14:41:00 +0000</pubDate><atom:updated>2008-08-21T12:51:30.179+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>introduction</category><category domain='http://www.blogger.com/atom/ns#'>hello world</category><category domain='http://www.blogger.com/atom/ns#'>xml</category><category domain='http://www.blogger.com/atom/ns#'>tutorial</category><category domain='http://www.blogger.com/atom/ns#'>php</category><category domain='http://www.blogger.com/atom/ns#'>simplexml</category><title>Introduction to SimpleXML with PHP</title><description>The &lt;a href="http://www.php.net/simplexml"&gt;SimpleXML&lt;/a&gt; php extension make it very easy to parse and create basic XML files.&lt;br /&gt;&lt;br /&gt;Here is a basic xml file that describes a message from one person to another:&lt;br /&gt;&lt;pre&gt;&amp;lt;?xml version='1.0'?&amp;gt;&lt;br /&gt;&amp;lt;message&amp;gt;&lt;br /&gt; &amp;lt;subject&amp;gt;Hello&amp;lt;/subject&amp;gt;&lt;br /&gt; &amp;lt;from&amp;gt;user@example.com&amp;lt;/from&amp;gt;&lt;br /&gt; &amp;lt;to&amp;gt;user2@example.com&amp;lt;/to&amp;gt;&lt;br /&gt; &amp;lt;body&amp;gt;Hello World&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/message&amp;gt;&lt;/pre&gt;&lt;br /&gt;If you create a file called test.xml with the content above then create a php file with the following, it will load in the xml file and output it as an SimpleXML object:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;$xml = simplexml_load_file("test.xml");&lt;br /&gt;print_r($xml);&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;Will output:&lt;pre&gt;SimpleXMLElement Object&lt;br /&gt;(&lt;br /&gt;    [subject] =&gt; Hello&lt;br /&gt;    [from] =&gt; user@example.com&lt;br /&gt;    [to] =&gt; user2@example.com&lt;br /&gt;    [body] =&gt; Hello World&lt;br /&gt;)&lt;br /&gt;&lt;/pre&gt;To reference a variable within the xml file you can use in the normal object way, e.g. $xml-&gt;subject&lt;br /&gt;&lt;br /&gt;To change the value of a variable, you can simply do the following:&lt;br /&gt;$xml-&gt;subject = "New Subject";&lt;br /&gt;&lt;br /&gt;And to output the new XML file:&lt;br /&gt;echo $xml-&gt;asXML();&lt;br /&gt;&lt;br /&gt;which returns:&lt;pre&gt;&amp;lt;?xml version="1.0"?&amp;gt;&lt;br /&gt;&amp;lt;message&amp;gt;&lt;br /&gt; &amp;lt;subject&amp;gt;New Subject&amp;lt;/subject&amp;gt;&lt;br /&gt; &amp;lt;from&amp;gt;user@example.com&amp;lt;/from&amp;gt;&lt;br /&gt; &amp;lt;to&amp;gt;user2@example.com&amp;lt;/to&amp;gt;&lt;br /&gt; &amp;lt;body&amp;gt;Hello World&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/message&amp;gt;&lt;br /&gt;&lt;/pre&gt;Any questions/feedback please leave a comment&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3679924792075541139-6488046066346887064?l=blog.webma.co.uk' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.webma.co.uk/2008/08/introduction-to-simplexml-with-php.html</link><author>noreply@blogger.com (James Lucas)</author><thr:total>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-3679924792075541139.post-9184359294586233512</guid><pubDate>Tue, 19 Aug 2008 13:26:00 +0000</pubDate><atom:updated>2008-08-23T18:13:19.916+01:00</atom:updated><category domain='http://www.blogger.com/atom/ns#'>crm</category><category domain='http://www.blogger.com/atom/ns#'>soap</category><category domain='http://www.blogger.com/atom/ns#'>eware</category><category domain='http://www.blogger.com/atom/ns#'>php5</category><category domain='http://www.blogger.com/atom/ns#'>sage crm</category><category domain='http://www.blogger.com/atom/ns#'>php</category><title>Connecting to Sage CRM with PHP</title><description>I was recently requested to find a way to integrate an online signup form with Sage CRM to allow for signups to be automatically added.  I decided to use PHP to do this as its &lt;a href="http://www.php.net/soap"&gt;SOAP&lt;/a&gt; integration is very easy to use:&lt;br /&gt;&lt;br /&gt;Below is example code that shows how to log into Sage using its SOAP interface and pass requests to it:&lt;br /&gt;&lt;br /&gt;Note: this example is PHP5 only.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;//allow for exceptions to be thrown from sage&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;        //define connection options, this allows for recording messages sent and received&lt;br /&gt;        $options = array('trace' =&gt; 1);&lt;br /&gt;&lt;br /&gt;        $client = new SoapClient("http://localhost/crm/eware.dll/webservice/webservice.wsdl", $options);&lt;br /&gt;&lt;br /&gt;        //username and password for sage (the user has to have web service access enabled)&lt;br /&gt;        $login_details  = array('username' =&gt; 'username',&lt;br /&gt;                                'password' =&gt; 'password');&lt;br /&gt;&lt;br /&gt;        //login to sage&lt;br /&gt;        $response = $client-&gt;logon($login_details);&lt;br /&gt;&lt;br /&gt;        //create header to send on future requests&lt;br /&gt;        $header = "&amp;lt;sessionheader&amp;gt;&amp;lt;sessionid&amp;gt;".$response-&gt;result-&gt;sessionid."&amp;lt;/sessionid&amp;gt;&amp;lt;/sessionheader&amp;gt;";&lt;br /&gt;        $session_var = new SoapVar($header, XSD_ANYXML, null, null, null);&lt;br /&gt;        $session_header = new SoapHeader('http://tempuri.org/type', 'SessionHeader', $session_var);&lt;br /&gt;&lt;br /&gt;        //apply header to client&lt;br /&gt;        $client-&gt;__setSoapHeaders(array($session_header));&lt;br /&gt;&lt;br /&gt;        //define lead data (or pull in from elsewhere), this is only some of the fields&lt;br /&gt;        //I will go into further detail on the fields in another blog post&lt;br /&gt;        $lead_data = array('companyname'     =&gt; 'company name',&lt;br /&gt;                           'companyaddress1' =&gt; 'address1',&lt;br /&gt;                           'personfirstname' =&gt; 'first name',&lt;br /&gt;                           'personlastname'  =&gt; 'last name',&lt;br /&gt;                           'status'          =&gt; 'In Progress');&lt;br /&gt;&lt;br /&gt;        //create soap variable to send&lt;br /&gt;        $lead = new SoapVar($lead_data, XSD_ANYTYPE, "lead", "http://tempuri.org/type");&lt;br /&gt;&lt;br /&gt;        //send request to sage&lt;br /&gt;        $response = $client-&gt;add(array('entityname' =&gt; 'lead', 'records' =&gt; $lead));&lt;br /&gt;&lt;br /&gt;        //check response&lt;br /&gt;        if (isset($response-&gt;result-&gt;records-&gt;crmid))&lt;br /&gt;        {&lt;br /&gt;             //worked, the lead id can be found in $response-&gt;result-&gt;records-&gt;crmid&lt;br /&gt;        }&lt;br /&gt;        else&lt;br /&gt;        {&lt;br /&gt;              //failed, display&lt;br /&gt;              echo "RESPONSE:\n" . $client-&gt;__getLastResponse() . "\n";&lt;br /&gt;        }&lt;br /&gt;}&lt;br /&gt;catch (Exception $e)&lt;br /&gt;{&lt;br /&gt;        //something went wrong, display request and response&lt;br /&gt;        echo "REQUEST:\n" . $client-&gt;__getLastRequest() . "\n";&lt;br /&gt;        echo "RESPONSE:\n" . $client-&gt;__getLastResponse() . "\n";&lt;br /&gt;&lt;br /&gt;        echo $e-&gt;getMessage();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Any questions/feedback please leave a comment&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3679924792075541139-9184359294586233512?l=blog.webma.co.uk' alt='' /&gt;&lt;/div&gt;</description><link>http://blog.webma.co.uk/2008/08/connecting-to-sage-crm-with-php.html</link><author>noreply@blogger.com (James Lucas)</author><thr:total>2</thr:total></item></channel></rss>