Facebookアプリケーションでコード化されたクライアント側があり、後で使用するためにトークンをサーバーに保存したい
'token'という変数があり、次に'apple'という新しい関数を作成して、この変数をjson形式でtxtファイルに書き込みます。
$(document).ready(function(){
$("#submit").click(function(){
//access token stuff
var token = $("#link_input").val();
//alert("Got Token: " + token + ". your application token");
if (token.split('#access_token=')[1]) {
var token = token.split('#access_token=')[1].split('&')[0];
//alert(token);
function WriteToFile(apple)
{
$.post("save.php",{ 'token': apple },
function(data){
alert(data);
}, "text"
);
return false;
}
私のphpファイル
<?php
$thefile = "new.json"; /* Our filename as defined earlier */
$towrite = $_POST["token"]; /* What we'll write to the file */
echo $towrite;
$openedfile = fopen($thefile, "w");
$encoded = json_encode($towrite);
fwrite($openedfile, $encoded);
fclose($openedfile);
return "<br> <br>".$towrite;
?>
しかし、私はそれを何も書くことができません