peterhuynh Posted February 15, 2015 Share Posted February 15, 2015 Hi, This is my third post and the first two were incredibly helpful. I'm learning a lot, so thank you contributers! This is what I'm working with:$nonce = time(); $token = ‘asdfghjklmnbvcxz’; $secret = ‘qwertyuioplkjhgfdsa’; $path = '/api2/user/order.json'; $params = array( 'amount' => '0.1', 'mode' => 'buy', 'currencypair' => 'BTCCAD', 'price' => '965.45' ); //param values must be appended in alphabetical order by key to the message $message = “{$nonce}{$token}{$path}0.1buy965.45”; $signature = hash_hmac(‘sha256’, $message, $secret); I ran the script but it doesn't work. I'm wondering about $path. How would the script know to go anywhere to get anything since it doesn't link to any website? Any ideas how to make it work? Thanks Link to comment https://forums.phpfreaks.com/topic/294629-how-does-path-variable-know-to-go-anywhere/ Share on other sites More sharing options...
Stew_822 Posted February 15, 2015 Share Posted February 15, 2015 G'day mate Good questions are asked by first defining what you want to do. To answer your question as you put it, the $path variable doesn't know how to go anywhere since it is simply a string (which is just a sequence of characters). You haven't told it to do anything, so it isn't going to do anything, which makes logical sense. If you let us know what you're trying to achieve, then I don't mind spending a few minutes helping you get there. Cheers, Stewart Link to comment https://forums.phpfreaks.com/topic/294629-how-does-path-variable-know-to-go-anywhere/#findComment-1505765 Share on other sites More sharing options...
peterhuynh Posted February 15, 2015 Author Share Posted February 15, 2015 On 2/15/2015 at 11:40 PM, Stew_822 said: G'day mate Good questions are asked by first defining what you want to do. To answer your question as you put it, the $path variable doesn't know how to go anywhere since it is simply a string (which is just a sequence of characters). You haven't told it to do anything, so it isn't going to do anything, which makes logical sense. If you let us know what you're trying to achieve, then I don't mind spending a few minutes helping you get there. Cheers, Stewart Thank you. The script is supposed to execute a buy order at a bitcoin exchange. This is the example given to me by the exchange. Link to comment https://forums.phpfreaks.com/topic/294629-how-does-path-variable-know-to-go-anywhere/#findComment-1505767 Share on other sites More sharing options...
Stew_822 Posted February 16, 2015 Share Posted February 16, 2015 Ah ok - I'm afraid I can't help you any further with that, I have no experience with bitcoins. I imagine you would need to use a function to send a message to the server, wait for the the server to respond, and then act based on the server's response. Link to comment https://forums.phpfreaks.com/topic/294629-how-does-path-variable-know-to-go-anywhere/#findComment-1505787 Share on other sites More sharing options...
kicken Posted February 16, 2015 Share Posted February 16, 2015 That code is just an example of how to generate a signature for the API request. There will be more code necessary to actually perform the request. Keep looking over their examples or ask their support for the rest of the code. Link to comment https://forums.phpfreaks.com/topic/294629-how-does-path-variable-know-to-go-anywhere/#findComment-1505832 Share on other sites More sharing options...
grissom Posted February 17, 2015 Share Posted February 17, 2015 Kicken is right. So far, all you've done is built up some strings which will need to be "sent" somewhere, somehow. So there will have to be some more lines of code needed to do that. Kicken's suggestion to look over their examples or to ask their support is excellent. Link to comment https://forums.phpfreaks.com/topic/294629-how-does-path-variable-know-to-go-anywhere/#findComment-1505896 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.