Now I have struggled with this coin as a developer for 2-3 days.. so this is my "final solution" to post in this thread.
This coin has the worst documentation for developers I have encounter in a long time. I hope they will release a better one when they have released the Source code.
I'm struggling with the HTTP api requests atm.. it seems that I can't execute POST commands and only GET commands through the HTTP requests.
Ex.
But I can't "post" transactions like this:
Since
all "POST" commands results in a "Method not allowed".
Anyone got any idea how to go around this?
function httpRequest($host, $port, $method, $path, $params, $jsonparams) {
$paramStr = "";
if($jsonparams == 1)
{
$paramStr = json_encode($params);
}
else
{
$paramStr = $params;
}
if (empty($method)) {
$method = 'GET';
}
$method = strtoupper($method);
if (empty($port)) {
$port = 80;
}
$sock = fsockopen($host, $port, $errno, $errstr, 5);
if($sock)
{
fputs($sock, "$method $path HTTP/1.1\r\n");
fputs($sock, "Host: $host\r\n");
fputs($sock, "Content-type: " .
"application/x-www-form-urlencoded\r\n");
if ($method == "POST") {
fputs($sock, "Content-length: " .
strlen($paramStr) . "\r\n");
}
fputs($sock, "Connection: close\r\n\r\n");
if ($method == "POST") {
fputs($sock, $paramStr);
}
$result = "";
while (!feof($sock)) {
$result .= fgets($sock,1024);
}
$result2 = strstr($result, "\r\n\r\n");
fclose($sock);
$result3 = json_decode($result2 , true);
return $result3;
}
else
{
return 'down';
}
}
$buf = httpRequest("127.0.0.1",
9085, "GET", "/addresses/validate/".$addr, '');
$buf = httpRequest("127.0.0.1",
9085, "POST", "/wallet/unlock", 'sfdPASSfds3', 0);
$buf = httpRequest("127.0.0.1",
9085, "POST", "/payment", array('amount' => $amount, 'fee' => '1.0', 'sender' => 'QXbn5VKQLUCbpHbmaQKRRpouTGXLtyWTut', 'recipient' => $addr), 1);
Try it.