Bank Interface Thread: Development

Moderators: Erik Mortis, (Shireroth) Steward, (Shireroth) Kaiser

Post Reply
Erik Mortis
Posts: 614
Joined: Mon Dec 06, 2010 6:19 am

Bank Interface Thread: Development

Post by Erik Mortis »

So... I've been researching.

interface.php would be the page. It would require a HTTPS connection (I might just make this bank wide...)

To use it just send a POST request, JSON encoded associative array named 'transfer' with the fields, username, password, destination, amount, reason and apikey.

I'm going to need to make a bank utility to generate API Keys, linked to certain accounts.

the script will send back the key/value 'error' which will have 0 for success or a variety of error codes. You can do with it as you please. hmm... I need to figure out where to send the response too. I think there is a $_SERVER[] variable for that.

I'm new to this webpage talking to each other stuff across domains, so Ari if I don't seem to know what I'm talking about let me know. I'll be paying you for consulting help btw.

Erik Mortis
Posts: 614
Joined: Mon Dec 06, 2010 6:19 am

Re: Bank Interface Thread: Development

Post by Erik Mortis »

And at this time I'm going to ask someone to pay 500 for this feature. Don't care who pays, but someone will have to pay for it. I might even talk to the SCUE about charing for API keys.

Thadeus Laing
Sea Elf, Sea Elf Run
Posts: 2247
Joined: Sat Dec 11, 2010 5:33 am

Re: Bank Interface Thread: Development

Post by Thadeus Laing »

I'll pay it. Sending the money.

pawelabrams
Posts: 88
Joined: Sun Jul 10, 2011 9:16 pm
Location: Novograd, Interland
Contact:

Re: Bank Interface Thread: Development

Post by pawelabrams »

the script will send back the key/value 'error' which will have 0 for success or a variety of error codes. You can do with it as you please. hmm... I need to figure out where to send the response too. I think there is a $_SERVER[] variable for that
Just 'echo' it ;) It will do - whether you're using file_get_contents with stream contexts or just curl.
Pavel' Abramovic: (vel Abrams)
President of the Republic of Interland

Erik Mortis
Posts: 614
Joined: Mon Dec 06, 2010 6:19 am

Re: Bank Interface Thread: Development

Post by Erik Mortis »

ok..why am I asking for an associative array..it'll come out as such.

Just encode an associative array with the following key/value pairs to the field name "transfer":
'username': (The source account)
'password': (Source password)
'amount': (funds to move)
'destination':(account to move money into)
'reason': (The reason the bank is to give in the log)
'apikey': (the apikey that grants access to the bank)

This should give me the JSON similar to: {"username":"someone","password","asecretword","amount":"123.45","destination":"someoneelse","reason":"whywetookit","apikey":"areallylongstring"}

From here I'll just call $_POST['transfer'] where ....wait.... I'm confused. I still need to specify the POST['transfer'] variable name.. well..technically that's on your end, but I still need to understand it.

Erik Mortis
Posts: 614
Joined: Mon Dec 06, 2010 6:19 am

Re: Bank Interface Thread: Development

Post by Erik Mortis »

Okey... I see how that would be done.

transfer=(JSONencodeddata)


moving on..How do I respond that things worked or failed..Do I just use header()? Or does that just go to the clients browser... I think I read something about just using header to respond. ...how would they read that... hmmm...

Erik Mortis
Posts: 614
Joined: Mon Dec 06, 2010 6:19 am

Re: Bank Interface Thread: Development

Post by Erik Mortis »

hmm...so... maybe it would just be easier to let people pass things as individual POST fields.. as in from a form... but I double people want to put thier API key in a hidden field, that can be seen in the source of their pages... so.. yeah.. no..

How do I know where to respond....?


OH here's what I was reading the other day!

POST it JSON encoded to interface.php on the bank server as field "transfer"

I do what I do with it.. and:

Code: Select all

$encoded = json_encode($response); //Where response is my response codes and stuff I haven't worked out. 
header('Content-type: application/json');
exit($encoded); 
http://eosrei.net/articles/2011/12/basi ... sponse-php

Erik Mortis
Posts: 614
Joined: Mon Dec 06, 2010 6:19 am

Re: Bank Interface Thread: Development

Post by Erik Mortis »

welll...shit... transfer_funds() throws internal error messages... meaning calling back header()will fail... So I have to rewrite bank_error() so they aren't visible...but... I need them visible.... Well.. maybe it's time to start logging error messages... or remove all those bank_error() functions...

Damn it.... I don't want to remove them..but I can't leave them.... problems problems...

pawelabrams
Posts: 88
Joined: Sun Jul 10, 2011 9:16 pm
Location: Novograd, Interland
Contact:

Re: Bank Interface Thread: Development

Post by pawelabrams »

Have you considered using ob_* functions? They provide a way to catch everything that is echo'ed without actually sending it to the client. You can still fetch the bank errors and save them to a variable, log them and stuff...

Code: Select all

exit($encoded);
And yeah, you could just echo $encoded; provided you don't have any code left after that. And I suppose you don't.
Pavel' Abramovic: (vel Abrams)
President of the Republic of Interland

Erik Mortis
Posts: 614
Joined: Mon Dec 06, 2010 6:19 am

Re: Bank Interface Thread: Development

Post by Erik Mortis »

I know not of these ob_*() functions. I will soon.

pawelabrams
Posts: 88
Joined: Sun Jul 10, 2011 9:16 pm
Location: Novograd, Interland
Contact:

Re: Bank Interface Thread: Development

Post by pawelabrams »

http://www.php.net/manual/en/ref.outcontrol.php - the manual covers pretty much everything about them :) I suppose that all you need is ob_start and ob_get_clean !
Pavel' Abramovic: (vel Abrams)
President of the Republic of Interland

Erik Mortis
Posts: 614
Joined: Mon Dec 06, 2010 6:19 am

Re: Bank Interface Thread: Development

Post by Erik Mortis »

Oh.. that is nice...

Post Reply

Return to “Esagila of Raynor”