I'm trying to parse some HTML. This is my code:
xml_parse_into_struct($p, $initpage, $values);
foreach ($values as $key => $val) {
if (($val['tag'] == 'INPUT') && ($val['attributes']['name'] == 'authenticity_token')) {
$token = $val['attributes']['value'];
break;
}
}
echo $token;
No problems with the curl or the XML parsing... I know that $values includes the goodies, as print_r($values) wil output, amongst other things, this:
[48] => Array ( [tag] => INPUT [type] => complete [level] => 8 [attributes] => Array ( [NAME] => authenticity_token [TYPE] => hidden [VALUE] => d76a4bec329537ac3322 ) )
When I try running the code, however, I get this error:
PHP Notice: Undefined variable: token in /media/.sda3/pjotr/scripts/tweet.php on line 49