Can you provide an PHP example? it seems like you want me to link to a file.php (which then takes args as a input), but i'm using controllers without extensions and would like to simply pass it to that :-)
i would really like if i could just do it in one line...
If you want to use Symfony, and your Symfony application is on the same host, you can do it simpler that using the whole curl/http/controller stuff, why don't you try to create and use a custom
console Command ?
Don't copy/paste the following example as I did not test it (just wrote like this), but this should work:
<?php
namespace App\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
class NotifyTransactionCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('my-app:notify-tx')
->setDescription('Call to notify a transaction')
->addArgument('txid', InputArgument::REQUIRED, 'The Transaction ID.')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
echo "Hey, I got a new transaction id: " . $input->get('txid') . "\n";
// do other stuff.
}
}
Your commande will be usable doing the following:
php /path/to/your/symfony-app/bin/console my-app:notify-tx THE_TX_ID
Then you'll be able to put in the Bitcoin's
bitcoin.conf configuration file:
walletnotify = php /path/to/your/symfony-app/bin/console my-app:notify-tx %s
If your symfony app is not on the same host than bitcoin's wallet, you have to use curl to reach the external web server. You can do a php script like this (again, wrote it quickly, didn't test it):
<?php
if(count($argv) != 2) {
echo "Usage: " . $argv[0] . " <txid>\n";
exit(1);
}
$txid = $argv[1];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://your-symfony-app-url.com/wallet/notify/" . $txid);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
And put in
bitcoin.conf:
walletnotify=php /path/to/your/script.php %s