Hi all, Can anyone help me doing status updates using twitter API with php?
I'm using Moises Limas' XMLHttpRequest class (http://hamen.us.com/ class.XMLHttpRequest.php.txt) Here is what I have so far: <?php function xml_to_array( $file ) { $parser = xml_parser_create(); xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, 0 ); xml_parser_set_option( $parser, XML_OPTION_SKIP_WHITE, 1 ); xml_parse_into_struct( $parser, file_get_contents($file), $tags ); xml_parser_free( $parser ); $elements = array(); $stack = array(); foreach ( $tags as $tag ) { $index = count( $elements ); if ( $tag['type'] == "complete" || $tag['type'] == "open" ) { $elements[$index] = array(); $elements[$index]['name'] = $tag['tag']; $elements[$index]['attributes'] = empty($tag ['attributes']) ? "" : $tag['attributes']; $elements[$index]['content'] = empty($tag['value']) ? "" : $tag['value']; if ( $tag['type'] == "open" ) { # push $elements[$index]['children'] = array(); $stack[count($stack)] = &$elements; $elements = &$elements[$index]['children']; } } elseif ( $tag['type'] == "close" ) { # pop $elements = &$stack[count($stack) - 1]; unset($stack[count($stack) - 1]); } } return $elements[0]; } require_once('/usr/local/www/Includes/xmltoarray.php'); $associatedpressrss[]="http://hosted.ap.org/lineups/SPTBASEBALL- rss_2.0.xml?SITE=NYONE&SECTION=HOME"; //print_r($associatedpressrss); for ($x=0; $x<count($associatedpressrss); $x++) { $xml=xml_to_array($associatedpressrss[$x]); for ($y=4; $y<sizeof($xml[children][0][children]); $y++) { $ajax_status_update=new XMLHttpRequest(); $ajax_status_update->open("POST", "http://twitter.com/statuses/" . urlencode($xml[children][0][children][$y][children][0][content]) . ".json", "true","gfne","password"); $ajax_status_update->send(null); $ajax_status_update_response=json_decode($ajax_status_update- >responseText); preg_match_all("|<[^>]+>(.*)</[^>]+>|U",$ajax_status_update_response, $ajax_status_update_response,PREG_PATTERN_ORDER); print_r($ajax_status_update_response); //echo urlencode($xml[children][0][children][$y][children][0] [content]) . "<br><br>"; } } ?>
