mck.workman Posted January 21, 2012 Share Posted January 21, 2012 Hey! I am trying to get a database table of users but am running into the error: Warning: file_get_contents(http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/template/NamlServlet.jtp?macro=user_nodes&user=68583) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 500 in get_user_from_parameter(nabble:utilities.naml:890) - <n.get_user_from_parameter.as_user_page.do/> - public v in C:\xampp\htdocs\website4js\stanford\loadUsernames.php on line 32 I have looked it up and it may be a security thing...The urls I am getting are http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/template/NamlServlet.jtp?macro=user_nodes&user=68583 but the error adds an nodes& part that screws it up. Any way around this? <?PHP $maxPage = 0; $mainPage = "http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/template/NamlServlet.jtp?macro=app_people&node=136"; $mainContent = file_get_contents($mainPage); $pattern = "/(?<=\"Page )\d\d+/"; preg_match_all($pattern, $mainContent, $pageNumb); //find the max page for($i=0;$i<sizeof($pageNumb[0]);$i++) { if($pageNumb[0][$i] > $maxPage) { $maxPage = $pageNumb[0][$i]; } } //echo('Max page is: '.$maxPage.'\n'); //Get an array of all the pages $pages = array(); for($i=1;$i<$maxPage;$i++) { $pages[$i] = "http://protege-ontology-editor-knowledge-acquisition-system.136.n4.nabble.com/template/NamlServlet.jtp?macro=app_people&node=136&i=".($i*20); } //print_r($userPages); //Get personal page urls and add to MySQL mysql_connect("localhost" , "root") or die("Cant connect"); mysql_select_db("protegeusers") or die("Cant find database"); foreach($pages as $url) { $urlContents = file_get_contents($url); $pattern = "/http:\/\/protege-ontology-editor-knowledge-acquisition-system\.136\.n4\.nabble\.com\/template\/NamlServlet\.jtp\?macro=.+;user=\d+/"; preg_match_all($pattern, $urlContents, $personalPage); foreach($personalPage as $user) { for($i=0; $i<sizeof($user);$i++) { [color=green]$userContents = file_get_contents($user[$i]);[/color] $pattern1 = "/user\/SendEmail\.jtp\?type=user.+;user=\d+/"; $pattern2 = "/(?<=\">Send Email to ).+(?=<)/"; preg_match_all($pattern1, $userContents, $userEmail); preg_match_all($pattern2, $userContents, $username); [color=green]print_r($username); print_r($email);[/color] //$query = "INSERT INTO users (username, userurl) values ('$userName','$userUrl')"; //mysql_query($query); } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/255473-functionfile-get-contents-failed-to-open-stream-http-request-failed/ Share on other sites More sharing options...
requinix Posted January 21, 2012 Share Posted January 21, 2012 A 500 error means a problem on the remote server. Is it your server too or what? Quote Link to comment https://forums.phpfreaks.com/topic/255473-functionfile-get-contents-failed-to-open-stream-http-request-failed/#findComment-1309816 Share on other sites More sharing options...
mck.workman Posted January 21, 2012 Author Share Posted January 21, 2012 No its not my server. I am tagging protege forum users locations (if they decide to add their locations) with google maps api (KML) so members can find other protege users in their area and connect. McK Quote Link to comment https://forums.phpfreaks.com/topic/255473-functionfile-get-contents-failed-to-open-stream-http-request-failed/#findComment-1309819 Share on other sites More sharing options...
requinix Posted January 21, 2012 Share Posted January 21, 2012 Well, like I said it's a problem on their server. Contact them and see if they can fix whatever the problem is. Or it could be that a 500 error means there's no location (or something like that) and you should do something different. Or something. Quote Link to comment https://forums.phpfreaks.com/topic/255473-functionfile-get-contents-failed-to-open-stream-http-request-failed/#findComment-1309822 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.