|
<?php |
|
// generic function to get the contents of an HTML block |
|
function get_inner_html( $node ) { |
|
$innerHTML= ''; |
|
$children = $node->childNodes; |
|
foreach ($children as $child) { |
|
$innerHTML .= $child->ownerDocument->saveXML( $child ); |
|
} |
|
return $innerHTML; |
|
} |
|
|
|
// username and password to use |
|
$usr = 'DOMAIN\USERNAME'; |
|
$pwd = 'PASSWORD'; |
|
// URL to fetch, this is the address of the RSS feed (go into a list and click "Actions" -> "View RSS Feed" to get the url) |
|
$url = "http://www.sharepointsite.com/_layouts/listfeed.aspx?List=%7BCED7CDDC-49C0-4C46-BDE6-CFC2BA993C84%7D"; |
|
//Initialize a cURL session |
|
$curl = curl_init(); |
|
//Return the transfer as a string of the return value of curl_exec() instead of outputting it out directly |
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
|
//Set URL to fetch |
|
curl_setopt($curl, CURLOPT_URL, $url); |
|
//Force HTTP version 1.1 |
|
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); |
|
//Use NTLM for HTTP authentication |
|
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_NTLM); |
|
//Username:password to use for the connection |
|
curl_setopt($curl, CURLOPT_USERPWD, $usr . ':' . $pwd); |
|
//Stop cURL from verifying the peer’s certification |
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
|
//Execute cURL session |
|
$result = curl_exec($curl); |
|
//Close cURL session |
|
curl_close($curl); |
|
|
|
$xml = simplexml_load_string($result); |
|
|
|
// display results on screen |
|
foreach($xml->channel->item as $Item){ |
|
echo "<br/>($Item->title) "; |
|
$doc = new DOMDocument(); |
|
$doc->loadHTML($Item->description); |
|
$ellies = $doc->getElementsByTagName('div'); |
|
foreach ($ellies as $one_el) { |
|
if ($ih = get_inner_html($one_el)) |
|
{ |
|
echo ", $ih"; |
|
} |
|
} |
|
} |
this is very useful! thanks a lot for sharing the code