を消去取得しているようだ私は、次のコードでHTMLフォームを使用して文字列を掲示しています:
<html>
<body>
<form name="form" enctype="multipart/form-data" action="test.php" method="post">
<input name="message"
type="text" value=""><br/><br/>
<input type="submit" value="Upload"/><br/>
</form>
</body>
</html>
test.phpをのためのコードを次のとおりです。
<html>
<head xmlns:testapp="https://apps.facebook.com/testapp/ns#">
<title>Test App</title>
</head>
<body>
<?php
echo "1".$_POST["message"];
$string1 = $_POST["message"];
echo "2".$string1;
$app_id = "191622610935428";
$app_secret = "a9cdd876cdaf17b6454639b19d91f157";
$my_url = "http://www.thepropagator.com/facebook/worldcentric";
$og_url = "http://thepropagator.com/facebook/worldcentric/issue.php?name=".$string1;
$code = $_REQUEST["code"];
if(empty($code)) {
$dialog_url = "https://www.facebook.com/dialog/oauth?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url) . "&scope=email,publish_actions";
echo("<script>top.location.href='" . $dialog_url . "'</script>");
}
$token_url="https://graph.facebook.com/oauth/access_token?client_id="
. $app_id . "&redirect_uri=" . urlencode($my_url)
. "&client_secret=" . $app_secret
. "&code=" . $code;
$access_token = file_get_contents($token_url);
// remove the @expires
$params = null;
parse_str($access_token, $params);
$access_token_updated = $params['access_token'];
$post_data = "issue=" . $og_url . "&access_token=" . $access_token_updated;
echo "post_data: " . $post_data . "<br/>";
// setup the POST
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://graph.facebook.com/me/testapp:raise?issue');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
// execute the POST
$result = curl_exec ($ch);
if(curl_error($ch))
{
echo 'error:' . curl_error($ch) . "<br/>";
}
curl_close ($ch);
echo "return code= " . $result . "<br/>";
?>
<br>
</br>
</body>
</html>
私は予想通り、私は、コードの最初のブロックで行うエコーが掲示文字列を示すが、いくつかの点で、彼らは消え、変数$ og_urlが連結された文字列を失い、フォームの提出ヒット。$ string1の。なぜこの変数が消えているのか誰もがなぜこれが起こっているのか説明できますか?
PHPエラーを生成する唯一の行は、次のとおりです。 $ access_token = file_get_contents($ token_url); そして、エラーの唯一の理由は、文字列$ og_urlに "name ="の後に何もないためです。
私の問題はコード行によって発生しているようです。 echo( "top.location.href = '"。$ dialog_url。 "'");
しかし私はなぜ、私はちょうどラインを取り除くことはできません。
このコードの構文は無効です。そこには、 '$ og_url.test'のようなナンセンスがたくさんあるようです。エラー報告( 'error_reporting(E_ALL); ini_set( 'display_errors'、true);')を有効にし、ステップバイステップデバッグを実行します。 – deceze
あなたが言及した行を削除し、error_log(コード変更を参照)を参考にしましたが、文字列変数$ string1の根本的な問題が$ access_token = file_get_contents($ token_url)行の前に消去されました。まだそこにいるようです。 –