I am getting an unexpected echo in my php error_log for echo $myData
I am trying to navigate to direct url to .php file so I believe this is why..... [I will add when I do this I see HTTP ERROR 500 due to the echo error]
The Error Log: [17-Jan-2017 22:28:59 America/New_York] PHP Parse error: syntax error, unexpected 'echo' (T_ECHO) in {Directories}get.php on line 17
PHP File
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<?php
require_once __DIR__ . '/src/Facebook/autoload.php';
$pid = 'pageid';
$aid = 'appid';
$asc = 'appsecret';
$token = $aid + '|'+ $asc;
$fb = new Facebook\Facebook($token);
$request = $fb->request('GET', '/'+$pid+'/Posts', array(
'fields' => 'message,created_time,permalink_url'
) );
$myData = json_encode($result)
echo $myData;
I will be using an html page to call the above script (Which does not appear to be working)
HTML FILE:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Title Goes Here</title>
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<script>
function myFunction(){
alert('Window Loaded'); //THIS WORKS! EVERYTHING BELOW HERE DOES NOT SEEM TO WORK//
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
data = JSON.parse(this.responseText);
document.getElementById("results").innerHTML = data;
}
};
xmlhttp.open("GET", "get.php", true);
xmlhttp.send();
};
</script>
</head>
<body onload="myFunction()"> //This does work to trigger my alert.
<p id="results">
This is my web page
</p>
</body>
</html>