Update of /cvsroot/phpwebsite-comm/modules/twitter/class
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22139/class
Modified Files:
Twitter_Runtime.php
Log Message:
Adding support for curl requests.
Index: Twitter_Runtime.php
===================================================================
RCS file: /cvsroot/phpwebsite-comm/modules/twitter/class/Twitter_Runtime.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Twitter_Runtime.php 2 Jun 2008 02:27:03 -0000 1.4
--- Twitter_Runtime.php 3 Jun 2008 03:37:30 -0000 1.5
***************
*** 23,26 ****
--- 23,28 ----
*/
+ PHPWS_Core::configRequireOnce('twitter', 'config.php');
+
class Twitter_Runtime
{
***************
*** 69,79 ****
{
$cache_key = 'twitter_' . $username;
$statuses = PHPWS_Cache::get($cache_key);
if (empty($statuses))
{
! $full_xml_array = PHPWS_Text::xml2php("http://twitter.com/statuses/user_timeline/$username.xml", 1);
! if (!empty($full_xml_array))
{
$tagged_xml_array = PHPWS_Text::tagXML($full_xml_array);
--- 71,117 ----
{
$cache_key = 'twitter_' . $username;
+ $url = "http://twitter.com/statuses/user_timeline/$username.xml";
$statuses = PHPWS_Cache::get($cache_key);
if (empty($statuses))
{
! /* Check for curl lib, use in preference to file_get_contents if available. */
! if (function_exists('curl_init'))
! {
! /* Initiate session */
! $oCurl = curl_init($url);
! /* Set options */
! curl_setopt_array($oCurl, array(
! CURLOPT_RETURNTRANSFER => true,
! CURLOPT_USERAGENT => 'phpWebSite',
! CURLOPT_CONNECTTIMEOUT => TWITTER_CONNECT_TIMEOUT,
! CURLOPT_TIMEOUT => TWITTER_TRANSFER_TIMEOUT,
! CURLOPT_DNS_CACHE_TIMEOUT => TWITTER_DNS_TIMEOUT
! ));
!
! /* Request URL */
! if ($sResult = curl_exec($oCurl))
! {
! /* Check for success. */
! if (curl_getinfo($oCurl, CURLINFO_HTTP_CODE) == 200)
! {
! $xml_parser = xml_parser_create();
! xml_parse_into_struct($xml_parser, $sResult, $arr_vals);
! xml_parser_free($xml_parser);
! $ordered_xml_array = PHPWS_Text::_orderXML($arr_vals);
! $full_xml_array = getXMLLevel($ordered_xml_array, 1);
! }
! }
!
! /* Close session */
! curl_close($oCurl);
! }
! else
! {
! $full_xml_array = PHPWS_Text::xml2php($url, 1);
! }
!
! if (isset($full_xml_array) && !empty($full_xml_array))
{
$tagged_xml_array = PHPWS_Text::tagXML($full_xml_array);
|