다음 코드를 사용하여 Twitter에서 일부 사용자 이름을 추출합니다. 지금까지 수행 에 무엇을 다음과 같이 얻을 :문서에서 특정 문자열을 추출하는 PHP 코드 수정
[0] => com/USERNAME/statuses/[email protected]
[1] => com/ANOTHER_USERNAME/statuses/[email protected]
이 내 코드는 ... 어떻게 만 사용자 이름을 추출 할 수있다?
$file = file_get_contents("http://search.twitter.com/search.rss?q=twitter");
$file = strip_tags($file);
preg_match_all("([a-z0-9!#$%&'*+/=?^_`{|}~-]*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)\b)siU", $file, $matches);
echo '<pre>';
print_r($matches);
echo '</pre>';
나는이 사용 SimpleXML을했다하지만 난 그 일을 첫 번째 결과
$url="http://search.twitter.com/search.atom?q=hello";
$twitter_xml = simplexml_load_file($url);
foreach ($twitter_xml->entry->author as $key) {
$author = $key->{"uri"};
echo"<li><h5>$author</h5></li>";
}
그래서 항상'패턴입니다 ... 코드를 요리 com' - 슬래시 - 이름 - 슬래시? 그렇다면 정규식은 필요하지 않습니다 ... – lonesomeday
다른 질문보기 : http://stackoverflow.com/questions/9199041/how-to-extract-the-content-of-uri-uri-in-a-xml-document – salathe