在 php 中执行 $_post 时出现错误

Getting Errors when doing a $_post in php

好的,我正在使用在这里找到的一些代码:Read feed on a Facebook page without login in

代码如下

proxy.php

<?php
// always add this header to ensure the JSON is output in the correct format
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
header('Content-Type: application/json; charset=utf-8'); 

$graphUrl = $_POST[graphUrl];
if ($graphUrl == "") {
    $graphUrl = "https://graph.facebook.com/684985445000793/posts";
}

//App Info, needed for Auth
$app_id = "MY-APP-ID";
$app_secret = "MY-APP-SECRET";

//retrieve auth token
$authToken = fetchUrl("https://graph.facebook.com/oauth/access_token?type=client_cred&client_id={$app_id}&client_secret={$app_secret}");

//Echo back json to read client side.
echo fetchUrl("{$graphUrl}?fields=ratings%2Cposts.limit(10)&access_token={$authToken}");

function fetchUrl($url){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 20);
    $retData = curl_exec($ch);
    curl_close($ch); 
    return $retData;
}
?>

index.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>FB reader</title>
</head>
<body>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {

            var timeout = 5000,
                load_error;

            load_error = function (jqXHR, textStatus, errorThrown) {
                if (errorThrown === "timeout") {
                    alert('Server bussy');
                } else {
                    alert('error: 404', textStatus + ": " + errorThrown);
                }
            };      

            $(document).ready(function() {
                console.log('Loading from Facebook...\n');

                $.ajax({
                    type: 'POST',
                    url: 'proxy.php',
                    data: {graphUrl: 'https://graph.facebook.com/684985445000793/'}, 
                    timeout:  timeout,
                    error: load_error,
                    success: function (rv) {
                        var data = rv.data,
                            len = data.length,
                            i,
                            out = '';
                        for (i = 0; i < len; i += 1) {
                            if (data[i].description) {
                                out += data[i].description + '\n\n';
                            }
                        }
                        console.log(out);
                    }
                });

            });
        });
    </script>
</body>
</html>

我的问题是

 type: 'POST',
                    url: 'proxy.php',
                    data: {graphUrl: 'https://graph.facebook.com/684985445000793/'}

我的 proxy.php 的错误日志中似乎没有工作 我被告知:

PHP Notice: Use of undefined constant graphUrl - assumed 'graphUrl' in proxy.php on line 8

所以我假设数据:来自我的 index.html 没有被发送过来。

我收到此错误的任何帮助或建议?

重要的是我在共享主机上....

$graphUrl = $_POST[graphUrl]; 应该是 $graphUrl = $_POST['graphUrl'];