SHARE
TWEET

Untitled

a guest Jan 14th, 2020 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function graphql_query(string $endpoint, string $query, array $variables = [], ?string $token = null): array
  4. {
  5.     $headers = ['Content-Type: application/json', 'User-Agent: Unknow Agent'];
  6.     if (null !== $token) {
  7.         $headers[] = "Authorization: bearer $token";
  8.         $headers[] = "X-Access-Token: $token";
  9.     }
  10.  
  11.     if (false === $data = @file_get_contents($endpoint, false, stream_context_create([
  12.         'http' => [
  13.             'method' => 'POST',
  14.             'header' => $headers,
  15.             'content' => json_encode(['query' => $query, 'variables' => $variables]),
  16.         ]
  17.     ]))) {
  18.         $error = error_get_last();
  19.         throw new \ErrorException($error['message'], $error['type']);
  20.     }
  21.  
  22.     echo $data;
  23.     //return json_decode($data, true);
  24. }
  25.  
  26. // balance
  27. $query = <<<'GRAPHQL'
  28. query StakeBalances($available: Boolean = false, $vault: Boolean = false) {
  29.    user {
  30.     id
  31.     name
  32.     balances {
  33.         available @include(if: $available) {
  34.             currency
  35.             amount
  36.         }
  37.         vault @include (if: $vault) {
  38.             currency
  39.             amount
  40.         }
  41.     }
  42.   }
  43. }
  44. GRAPHQL;
  45.  
  46. // mines bet
  47. $query_bet = <<<'GRAPHQL'
  48. mutation minesBet($amount: Float!, $currency: CurrencyEnum!, $minesCount: Int!, $fields: [Int!]) {  minesBet(amount: $amount, currency: $currency, minesCount: $minesCount, fields: $fields) {    ...CasinoBetFragment    state {      ...MinesStateFragment      __typename    }    __typename  }}fragment CasinoBetFragment on CasinoBet {  id  active  payoutMultiplier  amountMultiplier  amount  payout  updatedAt  currency  game  user {    id   balances {  available {   currency   amount   __typename  }  __typename  }  name    __typename  }  __typename}fragment MinesStateFragment on CasinoGameMines {  mines  minesCount  rounds {    field    payoutMultiplier    __typename  }  __typename}
  49. GRAPHQL;
  50.  
  51. // buat dapetin bet id
  52. $query_id = <<<'GRAPHQL'
  53. query Betiid($betId: String!) {  bet(betId: $betId) {   id   iid    __typename  }}
  54. GRAPHQL;
  55.  
  56. // graphql_query("https://api.stake.com/graphql", $query_bet, ['amount' => 0, 'currency' => 'btc', 'minesCount' => 3, 'fields' => [0,1,2,3,4,5]],"token");
  57.  
  58. graphql_query("https://api.stake.com/graphql", $query_id, ['betId' => '7baa246d-44f0-4bb6-8df7-139500abab4d'],"token");
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top