JSON manipulation pack

nickquest

  • Posts: 60
Does this manipulation pack no longer exist? I can't find it on the Forge. Was it only compatible with older versions of Stencyl?

captaincomic

  • *
  • Posts: 6108
Yes, only compatible with older versions (the OP mentioned using AS3 which was the language used for Stencyl before 3.0). Older resources are hidden from Forge when you use 3.x. You could probably find this on Forge with a version of 2.x, but it won't be compatible with 3.x anyway.

If you know a little bit of code, you can use haxe's JSON API now.

dripple

  • Posts: 747
Have a look at this thread, we discussed this a couple of months ago for a weather application.
Sure, my games won't get better with all the new features of Stencyl.
But I do have more fun creating bad ones.


MayazCastle Keeper

nickquest

  • Posts: 60
Thanks to both of you for the quick replies. I'm not a programmer by trade, so this is probably a bit beyond me, but I'm working with a PHP developer to integrate some additional functionality into a mobile game I'm making in Stencyl. So he should be able grasp this. Thanks again. :D

« Last Edit: August 05, 2014, 10:57:46 am by nickquest »

nickquest

  • Posts: 60
What I want to do with JSON is implement crypto coin payouts and possibly purchases into my game, Flash only version. I want players to be able to cash out their points for crypto coins. Below is the current API for the online wallet of a  crypto currency called Coin2 that I want to use, but I'm pretty lost at putting together anything but logic blocks. I'm assuming I should use the code block and just drop the JSON functions into it. Any help or suggestions would be greatly appreciated. Ideally I would like to build a custom block or extension that anyone can use to implement crypto payments into their Stencyl games.

API

This page describes the JSON API interface available to wallet users. This interface may be used by users to interface their own games and applications into their online C2 Wallet.
Enjoy
Sample PHP code - Send Payment

$url = "http://coin2online.com/wallet/json";

$data = array();
$data['username'] = 'jsmith@c2gaming.com'; // Your Web Wallet userid
$data['password'] = 'e29jh!25Z_'; // Your Web Wallet password
$data['walletid'] = 'secretid'; // The name you gave to your Web Wallet
$data['request'] = 'sendtoaddress'; // The C2 address you want to send to
$data['param1'] = 'CVeCYv39eqLGAUWe3xxMhP6gF39jgbgZ7i'; // Enter address to pay to
$content = json_encode($data); // Encode $jdata for sending to the C2 JSON URL

// Following code curtesy of stackoverflow on internet
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER,
array("Content-type: application/json"));
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);

$json_response = curl_exec($curl);

$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if ( $status != 201 ) {
die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl));
}

curl_close($curl);

$response = json_decode($json_response, true);

Note : Parameters should be labelled param1 ... param5 if required

This produces :
{
"username":"jsmith@c2gaming.com",
"password":"e29jh!25Z_",
"walletid":"secretid",
"request":"getbalance"
"param1":"CVeCYv39eqLGAUWe3xxMhP6gF39jgbgZ7i"
}
Commands available

getaccountaddress

{ "username":"myusername", "password":"mypassword", "walletid":"mywalletid", "request":"getaccountaddress" }

Response :

"CGtAbZA3iaFSkRjgX1EMLWRcKt8DHeSLTC"

getaddressesbyaccount

{ "username":"myusername", "password":"mypassword", "walletid":"mywalletid", "request":"getaddressesbyaccount" }

Response :

["CNudTMfLBUGcSYo6L6fNwdW12WMdhGc5xP","CLaYgqzbTs2by6tgLEPfqmRWcbh58B9Dcu","CZUoimdCvq3zpNfs8wvLxJrYY6ftGpBGT3","CH949duBYXwDgjmt7BSB44FiCojzpEPKnQ","Ce4DUZD9t77RgUtrzWjKnoVMhKguv6SRBu","CZJPAfcwmiHMsixrtze8KHppHnZUmGW6jq","CRQqC2i1JwtsGDGKz6d2afk19JQTPieHmS","Cde8ea84UXxzUQ2x7krQwHPsAXEe7q4MxY"]

getbalance

{ "username":"myusername", "password":"mypassword", "walletid":"mywalletid", "request":"getbalance" }

Response : 547.23456

getnewaddress

{ "username":"myusername", "password":"mypassword", "walletid":"mywalletid", "request":"getnewaddress" }

Response :

"CNudTMfLBUGcSYo6L6fNwdW12WMdhGc5xP"

getreceivedbyaccount

{ "username":"myusername", "password":"mypassword", "walletid":"mywalletid", "request":"getreceivedbyaccount" }

Response :

3024.51278

getreceivedbyaddress

{ "username":"myusername", "password":"mypassword", "walletid":"mywalletid", "request":"getreceivedbyaddress", "parm1":"CNudTMfLBUGcSYo6L6fNwdW12WMdhGc5xP" }

Response :

2345.12542

gettransaction

{ "username":"myusername", "password":"mypassword", "walletid":"mywalletid", "request":"gettransaction" "parm1":"8a130a495fa6b3ef3545220c2742cb92e8f61a5f072154d31da85492fe2c9459" }

Response :

Response : {"txid":"8a130a495fa6b3ef3545220c2742cb92e8f61a5f072154d31da85492fe2c9459","version":1,"time":1409007335,"locktime":0,"vin":[{"txid":"bb841e0bbf397ff0560c0f1d4bec2e351395f4afb292cec8370142ee2c4c8f36","vout":1,"scriptSig":{"asm":"3045022100cbc4df70124423891a2bc18a978e132489373f3539f8733740c697a8a4561fe602201c1884db2fd48cbb0aa31d2d84253e14f1a89264d336eef05376669827c57ed301 02530c55928cea1a54bca818ab1aa6782f734ed27397e93c3b0ecdd4010b7f9889","hex":"483045022100cbc4df70124423891a2bc18a978e132489373f3539f8733740c697a8a4561fe602201c1884db2fd48cbb0aa31d2d84253e14f1a89264d336eef05376669827c57ed3012102530c55928cea1a54bca818ab1aa6782f734ed27397e93c3b0ecdd4010b7f9889"},"sequence":4294967295}],"vout":[{"value":44.99,"n":0,"scriptPubKey":{"asm":"OP_DUP OP_HASH160 d01f4b168c4f27dd3cea55afc92342c670b5c40f OP_EQUALVERIFY OP_CHECKSIG","hex":"76a914d01f4b168c4f27dd3cea55afc92342c670b5c40f88ac","reqSigs":1,"type":"pubkeyhash","addresses":["CbSLcEqsoNupqhnHyQ7mvnsAGHpLmJP2LL"]}},{"value":55,"n":1,"scriptPubKey":{"asm":"OP_DUP OP_HASH160 46aef3bf4e52b3c8afd05b53eed7784d9fb5363a OP_EQUALVERIFY OP_CHECKSIG","hex":"76a91446aef3bf4e52b3c8afd05b53eed7784d9fb5363a88ac","reqSigs":1,"type":"pubkeyhash","addresses":["CNudTMfLBUGcSYo6L6fNwdW12WMdhGc5xP"]}}],"amount":55,"confirmations":5067,"blockhash":"c5d3984f40a43a877797c94746b936057601d35dca03f5f3f8ebf2b1df9fb9e6","blockindex":2,"blocktime":1409007438,"timereceived":1409007335,"details":[{"account":"secretid","address":"CNudTMfLBUGcSYo6L6fNwdW12WMdhGc5xP","category":"receive","amount":55}]}

listtransactions

{ "username":"myusername", "password":"mypassword", "walletid":"mywalletid", "request":"listtransactions", "parm1":"nooftransactions" }

Response :

Response : [{"account":"secretid","address":"CNudTMfLBUGcSYo6L6fNwdW12WMdhGc5xP","category":"receive","amount":55,"confirmations":5072,"blockhash":"c5d3984f40a43a877797c94746b936057601d35dca03f5f3f8ebf2b1df9fb9e6","blockindex":2,"blocktime":1409007438,"txid":"8a130a495fa6b3ef3545220c2742cb92e8f61a5f072154d31da85492fe2c9459","time":1409007335,"timereceived":1409007335},{"account":"secretid","address":"CUFJ2tcgkUzGvCXF3NhZJAXx3tzUxQzbZR","category":"send","amount":-5,"fee":-0.01,"confirmations":4796,"blockhash":"0b61bf36b0393d2c23f1c1158b078330baacbf9083af9603aa809aab89223d16","blockindex":2,"blocktime":1409023410,"txid":"10329f6057d86661d73abc1e2c0fb3492e1051f08f2f0397a7dfa498389bbee7","time":1409023409,"timereceived":1409023409,"comment":"Test_Nelz"},{"account":"secretid","address":"CUT5VUrpvr3dNo3FYjJGeXEMEAsWwgrxJL","category":"send","amount":-0.01,"fee":-0.01,"confirmations":1216,"blockhash":"db3e0e0fe02521823c3719bcbb21b025aba0af483fb3508ed57572d67c653a6f","blockindex":2,"blocktime":1409233863,"txid":"4e7834958875c0df4432ccc1fcdd669f91438cbe7df3981884fbcdbbe539bb96","time":1409233826,"timereceived":1409233826,"comment":"Drs3"}]

sendtoaddress

{ "username":"myusername", "password":"mypassword", "walletid":"mywalletid", "request":"sendtoaddress", "parm1":"address" }

Response : Transaction id

"3245d0e99375adb546c18ed96750ad8d4373d34a8899c23ac2389c18bb6e9c81"

validateaddress

{ "username":"myusername", "password":"mypassword", "walletid":"mywalletid", "request":"validateaddress", "parm1":"address" }

Response :

{"isvalid":true,"address":"CUT5VUrpvr3dNo3FYjJGeXEMEAsWwgrxJL","ismine":false}