Bitcoin Forum
June 17, 2024, 06:37:30 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: newbi mtgox API help, basic php  (Read 739 times)
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
April 15, 2013, 07:59:58 PM
 #1

just started accepting btc donations on my site.

right now its just getting stored on mtgox so It can keep a portion in dollars.

I want to set up a "getinfo" so I can see how much is in my account. And Eventually set up an automated monthly withdrawl of bitcoin to a offline wallet.

I found a github of what looks like a simple php mtgox api class

https://github.com/Someguy123/MtGOX-PHP-API


here is my code so far

Code:
<?php
$gox 
= new Gox('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS');


include (
"gox.class.php");
echo 
"test";
$info->getinfo($gox);
var_dump ($info);
?>


for refece the function im trying to call too is

Code:
function getInfo() {
        $info = $this->mtgox_query('0/info.php');
        $this->info = $info; // Hold it in a variable for easy access
        return $info;
    }

thanks
cmp
Newbie
*
Offline Offline

Activity: 15
Merit: 0


View Profile
April 15, 2013, 08:03:03 PM
 #2

Look at the API code here: https://en.bitcoin.it/wiki/MtGox/API/HTTP#PHP

I think it's easier to understand. The Gox.class is using this code.
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
April 15, 2013, 08:07:28 PM
 #3

ohh wow, yea that worked much better. just entered my API info and got my var_dump


Im going to be trying to set up a withdrawal now and see If I run into any trouble.
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
April 15, 2013, 09:24:55 PM
Last edit: April 16, 2013, 06:21:12 AM by BitvoinVender
 #4

im stuck!

I take it this is an old API

Code:
// old api (get funds)
var_dump(mtgox_query('0/getFunds.php'));
 
// trade example
// var_dump(mtgox_query('0/buyBTC.php', array('amount' => 1, 'price' => 15)));



I found a new class for v1

https://github.com/daftspunk/php-mtgox-v1


this is what I got so far.

Code:
<?php
include ("mtgox_private_api.php");
include (
"mtgox_api_base.php");
include (
"mtgox_api_objects.php");
 
 
$api = new MtGox_Private_Api();
$api->set_currency('USD');
$api->set_authentication('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS');
 
 
$history $api->get_wallet_history('USD');
print_r($history);
 
 
//withdrawl sample 1btc
$address "1PetPrN5xDimsYENtJNW6gBUbmjZ5H9xdm";
$amount_int "100000000";
$fee_int".0005";
 
$withdrawl $api->withdraw_coins($address$amount_int$fee_int=null$no_instant=null$green=null);
 
//print recipt?
var_dump ($this);
 
echo 
"test";
 
?>




http://25.media.tumblr.com/tumblr_lsxtglsUrC1qmhv2lo1_500.jpg
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
April 16, 2013, 03:54:44 AM
 #5

bump Embarrassed
OdinHephaestus
Member
**
Offline Offline

Activity: 70
Merit: 10



View Profile
April 16, 2013, 03:57:44 AM
 #6

Code:
<?php
include ("gox.class.php");

$gox = new Gox('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS');

echo 
"test";
$info->getinfo($gox);
var_dump ($info);
?>

You need to include the file, before you can call the class.

Bitcoin: 1odinQ5YUdbfuopNF2D1FZRN8qcrC4y1L
Litecoin: LeodinXzG7CgHqPDZxaUgsDKUKBUu46qa5
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
April 16, 2013, 06:19:52 AM
 #7

im useing the newer API v1 then that original post.

this is an example useing the class

https://github.com/daftspunk/php-mtgox-v1/blob/master/examples/dirty_daytrader.php

why I tried the 3 includes

include '../mtgox_api_base.php';
include '../mtgox_private_api.php';
include '../mtgox_public_api.php';

not a withdrawl in their :/


simply trying to call to this function

Code:
// Send bitcoins from your account to a bitcoin address. 
    public function withdraw_coins($address, $amount_int, $fee_int=null, $no_instant=null, $green=null)
    {
        return $this->send_request(self::uri_withdraw_coins);
    }
BitvoinVender (OP)
Newbie
*
Offline Offline

Activity: 46
Merit: 0


View Profile
April 16, 2013, 07:31:09 AM
 #8

I got it to connect;

Code:
$history = $api->get_wallet_history('USD');
print_r($history);

dumps my history

yet, still trying to figure out withdrawls

Code:
include ("mtgox_api_base.php");
include ("mtgox_private_api.php");
include ("mtgox_public_api.php");

//include ("mtgox_api_objects.php");

echo "test";

$api = new MtGox_Private_Api();
$api->set_currency('USD');
$api->set_authentication('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS');



$history = $api->get_wallet_history('USD');
print_r($history);





//withdrawl sample 1btc
$address = "1PetPrN5xDimsYENtJNW6gBUbmjZ5H9xdm";
$amount_int = "90000000";
$fee_int= "000000000";

$withdrawl = $api->withdraw_coins($address, $amount_int, $fee_int=null, $no_instant=null, $green=null);

//print recipt?
print_r ($withdrawl);

echo "test";

assume amount is in satoshi?
Im not even getting an error or anything, just a white page with the "test" showing
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!