I am working on a client site which is on a default cent-os system that comes with php 5.1.7. This PHP version doesn't natively come with the PHP JSON library, but it does come with the SimpleXML library.
I made some modifications to your twitter_pull class that allow for a variable_get to decide if the system should use xml or json. The changes only required the addition of the variable_get, some variable use to point to .xml|.json by variable, and I put the json_decode() into a ->decode() method.
All in all I have ~15 lines changed, and it now works with the xml method, using simplexml.
The new var:
$format = variable_get('twitter_pull_format','xml');
An example of using the var:
$url = 'http://api.twitter.com/1/'. urlencode($username) .'/lists/'. urlencode($listname) .'/statuses.'.$format.'?per_page='. $num;
This is the new decode:
function decode( $data ) {
switch (variable_get('twitter_pull_format','xml')) {
case 'json':
return json_decode($data);
case 'xml':
return new SimpleXMLElement( $data );
}
}
Attached is the patch. Can you please check it and decide if it is worth while to include it in your source. I know that PHP 5.1.7 is horribly outdated, but the code uses a fallback to JSON, and makes it work on this default CENTOS machine.
(I just realized that I might have had my order of files in my diff statement backwards, if so let me know and I'll run it again.)
| Comment | File | Size | Author |
|---|---|---|---|
| patch.tar_.gz | 579 bytes | jaxxed |