hKit implementation

7 views
Skip to first unread message

Sean

unread,
Feb 4, 2008, 11:56:17 AM2/4/08
to hkit-discuss
Hi guys, I found hKit a while ago - and have a quick question if you
don't mind.

I set it up on one domain running PHP 5 with SimpleXML active and it
ran fine.


--------------------------------------------------------------------------------

Config details:
PHP Version 5.2.3
SimpleXML:
Simplexml support enabled
Revision $Revision: 1.151.2.22.2.26 $
Schema support enabled




--------------------------------------------------------------------------------


I'd now like to transfer it from that server onto another one. This
one is also running PHP 5 with SimpleXML.

Only thing is I'm now getting the message hKit error: these required
functions are not available: dom_import_simplexml()


--------------------------------------------------------------------------------


Config details:
PHP Version 5.1.6
SimpleXML:
Simplexml support enabled
Revision $Revision: 1.151.2.22 $
Schema support enabled




--------------------------------------------------------------------------------


I've searched on the web and can't understand why the function would
not be available.

Any ideas what I need to do to get this up and running on this server?

Thanks in advance for your help

Sean

Drew McLellan

unread,
Feb 4, 2008, 12:22:04 PM2/4/08
to hkit-discuss
Hi Sean

This is actually a requirement for DOM rather than SimpleXML. The
dom_import_simplexml() imports a SimpleXML node into DOM.

http://uk.php.net/manual/en/ref.dom.php

It's been a good while since I wrote that part of the code, but I
think I switched into DOM to get around a limitation in SimpleXML.
(Although that may, of course, have just been a limitation in me not
fully understanding how to do what I needed with SimpleXML!)

So I suggest installing DOM if you've not got it. Apologies - it's
rather moronic that hkit requires two different methods of parsing
XML! I really must revisit that part of the code.

Drew.

Sean

unread,
Feb 5, 2008, 5:58:39 AM2/5/08
to hkit-discuss
Great, I've sorted it - thanks for the quick reply Drew.

I'm new to all the server-side stuff, but my colleague did the
following in Putty:

yum install php-xml

Then rebooted Apache and it's working fine now.

phpinfo() still says '--disable-dom' but hKit is running with no
errors, so I'm happy with that!

----------------------------

I have another problem - this should be a bit easier to fix though I
think :)

I'm using Ajax to call a php script to look for the hCard and the
result is returned in JSON format.

The user types in their user name of, say, flickr and this is sent
through to the script using Ajax with the 'get' method.

This works fine, and returns correctly if there are no numbers or
special characters, eg '&', in the url, but otherwise just hangs.

Also, it works fine with numbers and special characters if I go to the
php page and append the url, eg
http://www.wooshare.com/hkit/get_profile.php?url=http://www.flickr.com/people/7307825@N08.

So I can only assume it's either something to do with the way I'm
sending the url through to the php script, or the way I'm sending the
url through to hKit.

Do I need to URL encode / decode or use htmlspecialchars?

Core code as follows:

$hKit = new hKit;

// Config options (see top of class file)
$hKit->tidy_mode = 'proxy'; // 'proxy', 'exec', 'php' or 'none'

if ($_GET['url']) {
$result = $hKit->getByURL('hcard', $_GET['url']);

if ($result) {
$o = ($json->encode($result));
$o = substr($o, 1, -1);
$ct = ($debug) ? 'text/plain' : 'application/json';
}
else {
$o = '404 Not Found';
$status = '404';
}
}
else {
$o = '400 Bad Request';
$status = '400';
}



header('Content-type: '.$ct);

switch($status) {
case '400':
header("HTTP/1.0 400 Bad Request");
break;

case '404':
header("HTTP/1.0 404 Not Found");
break;

case '200':
default:
header("HTTP/1.0 200 OK");
break;
}

print $o;

----------------------------

Many thanks for your help!

Sean

----------------------------

Sean

unread,
Feb 5, 2008, 6:50:40 AM2/5/08
to hkit-discuss
It's ok I've fixed it..

For some reason, if the username doesn't contain any numbers or
special characters, the json returns surrounded in square brackets -
which my Ajax script didn't like, hence the line in my code $o =
substr($o, 1, -1);

If the username has either number or special characters, the json is
not surrounded in square brackets.. no idea why(?)..

So I just put in the following code and it works:

if (substr($o, 0, 1)=="["){
$o = substr($o, 1, -1);
}

- more of a botch up than proper coding, but it seems to work now!

Anyone else experienced this?

Many thanks

Sean

On Feb 5, 10:58 am, Sean <sean.wil...@feelcreative.com> wrote:
> Great, I've sorted it - thanks for the quick reply Drew.
>
> I'm new to all the server-side stuff, but my colleague did the
> following in Putty:
>
> yum install php-xml
>
> Then rebooted Apache and it's working fine now.
>
> phpinfo() still says '--disable-dom' but hKit is running with no
> errors, so I'm happy with that!
>
> ----------------------------
>
> I have another problem - this should be a bit easier to fix though I
> think :)
>
> I'm using Ajax to call a php script to look for the hCard and the
> result is returned in JSON format.
>
> The user types in their user name of, say, flickr and this is sent
> through to the script using Ajax with the 'get' method.
>
> This works fine, and returns correctly if there are no numbers or
> special characters, eg '&', in the url, but otherwise just hangs.
>
> Also, it works fine with numbers and special characters if I go to the
> php page and append the url, eghttp://www.wooshare.com/hkit/get_profile.php?url=http://www.flickr.co....
Reply all
Reply to author
Forward
0 new messages