I downloaded someone's project on GitHub that enabled Facebook users to send Bitcoin to each other. He abandoned development a year ago, and I want to build my own application but I am currently looking at his code and trying to get my development environment set up.
I understand PHP kinda, that its meant for server side scripting and that JavaScript is executed on a client machine (all in the browser, and Node.js is a server side framework)
Anyways, he's doing something peculiar, and its producing an error.
The directory structure is as follows:
inc/
init.php
app.php
btc.php
index.php
settings.php
With many more files but the above will suffice I think.
So I run the command "php -S localhost:8000" and it starts a server
I go to localhost and once the page renders I get these errors in the terminal:
[Sat Apr 12 02:23:11 2014] PHP Notice: Undefined variable: app_url in /home/arthur/projects/bfb/index.php on line 21
[Sat Apr 12 02:23:11 2014] PHP Notice: Undefined variable: callback_url in /home/arthur/projects/bfb/index.php on line 22
[Sat Apr 12 02:23:11 2014] PHP Fatal error: Call to undefined function get_x_rates() in /home/arthur/projects/bfb/index.php on line 23
[Sat Apr 12 02:23:11 2014] 127.0.0.1:59511 [200]: / - Call to undefined function get_x_rates() in /home/arthur/projects/bfb/index.php on line 23
[Sat Apr 12 02:23:11 2014] 127.0.0.1:59512 [200]: /stylesheets/reset.css
[Sat Apr 12 02:23:11 2014] 127.0.0.1:59513 [200]: /stylesheets/btc.css
[Sat Apr 12 02:23:11 2014] 127.0.0.1:59514 [200]: /javascript/chosen.css
[Sat Apr 12 02:23:21 2014] 127.0.0.1:59515 Invalid request (Unexpected EOF)
[Sat Apr 12 02:23:21 2014] 127.0.0.1:59516 Invalid request (Unexpected EOF)
The index.php file has the following general structure:
<?php
//error_reporting(E_ALL);
//ini_set("display_errors", 1);
require 'settings.php';
require 'inc/btc.php';
require 'inc/app.php';
require 'inc/init.php';
?>
<!DOCTYPE html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<meta charset="utf-8" />
<title>Bitcoin Transactions</title>
<link rel="stylesheet" href="stylesheets/reset.css" type="text/css" />
<link rel="stylesheet" href="stylesheets/btc.css" type="text/css" />
<link rel="stylesheet" href="javascript/chosen.css" type="text/css" />
<script>var appurl='<?=$app_url?>',
hosturl='<?=$callback_url?>',
rates=<?=get_x_rates()?>;</script>
<script type="text/javascript" src="javascript/jquery-1.7.1.min.js"> </script>
<script type="text/javascript" src="javascript/chosen.jquery.min.js"></script>
<script type="text/javascript" src="javascript/btc.js"></script>
</head>
<body>
....
</body>
</html>
Since he's loading the PHP files in the beginning of the html file, why can't it see the variables I've defined in this settings.php file:
<?
$bucket_addr='-taken-out-for-Stack-Overflow';
$callback_url='https://super-lame-name-1231232.herokuapp.com/';
$app_url='https://apps.facebook.com/c------------------n';
$blockchain_guid="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
$blockchain_pw="xxxxxxxxxxxxxxxx";
$fb_settings=array(
'appId' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
);
$fb_tx_fee=10000; //in satoshi (0.0001 BTC)
$btc_tx_fee=50000; //in satoshi (0.0005 BTC)
$tx_per_page=10;
$revert_duration="60 days";
Thanks for any help!!