Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql item base #85

Closed
Xeroner opened this issue Nov 30, 2015 · 19 comments
Closed

Mysql item base #85

Xeroner opened this issue Nov 30, 2015 · 19 comments

Comments

@Xeroner
Copy link

Xeroner commented Nov 30, 2015

Hello, can anybody update item database ? Becouse it's realy realy old and have a lot of 0 prices.
@ztizzlegaming

@Stuffa1991
Copy link

If you delete the 0 prices, it uses the prices directly from the market :)

@Xeroner
Copy link
Author

Xeroner commented Dec 1, 2015

And then for time to time steam blocking connection :)

@Stuffa1991
Copy link

Worked on a method getting prices via www.bitskins.com api, both csgojackpot and csgowild uses it

And it managed to work it out last night, i can tell what to do tomorrow :)

@Xeroner
Copy link
Author

Xeroner commented Dec 1, 2015

Fully free and unlimited?

@Stuffa1991
Copy link

Its free and you can do 8 requests a second :)

@Xeroner
Copy link
Author

Xeroner commented Dec 1, 2015

8 is to small i think for bigger jackpot

@Stuffa1991
Copy link

You can contact them to gain more, but i think that cost extra :) ill release a detailed guide or just the files if people wants it, going to bed soon :)

@GreYzZ
Copy link

GreYzZ commented Dec 2, 2015

@Stuffa1991
can you share the implemention of the API with us?

@Stuffa1991
Copy link

Okay i'll make this as detailed as i can :)

I tried making the code i made so versatile so you only have to change the URL in check-items.php

Step by Step

  1. Create an Account on BitSkins.com
  2. Create Two-Factor Authentication - https://bitskins.com/settings
    In this step its important you write down the "secret" code right under the QR code
    Write it down or remember it, it will be needed later
  3. Create API access
    Write down your api-key it will be needed later

Thats it for BitSkins.com, you can close it now :)

Now to the important parts

Create a file called GoogleAuthenticator.php
Paste this in http://codeshare.io/ROdWA

Create a file called price.php
Paste this in http://codeshare.io/fRELz

  1. Upload this to a folder on your website.
  2. Change $secret in price.php to the secret from under the QR from bitskins
  3. The same with $api, change that to the api-key provided by bitskins
  4. In php/check-items.php change the URL of $marketObj from
$marketObj = json_decode(file_get_contents("http://steamcommunity.com/market/priceoverview/?currency=1&appid=730&market_hash_name=$hash"), true);

to

$marketObj = json_decode(file_get_contents("http://yourwebsite.com/php/price.php$hash"), true);

And thats about it, your bot should now retrieve bitskins prices, which are used by csgowild and csgojackpot :)

@rfalkner
Copy link

rfalkner commented Dec 3, 2015

I followed your guide 100% @Stuffa1991 - how can i check if my prices update? And when will they update?

Best regards

@Xeroner
Copy link
Author

Xeroner commented Dec 3, 2015

@rfalkner you need to replace steamcommunity lines to this script. This will not update your database man. It's should check price when user joining the pot.

@Stuffa1991
Copy link

@rfalkner, to keep the prices you have to add something in the check-items.php

Like so on line 136~

if (isset($medianPrice)) {
            $price = doubleval(substr($medianPrice, 1)) * 100;
            $sql = "INSERT INTO items (marketName, avgPrice30Days) 
                    VALUES (:marketName, :avgPrice30Days)
                    ON DUPLICATE KEY UPDATE avgPrice30Days = :newPrice";
            $stmt = $db->prepare($sql);
            $stmt->bindValue(':marketName', $marketName);
            $stmt->bindValue(':avgPrice30Days', $price);
            $stmt->bindValue(':newPrice', $price);
            $stmt->execute();
        } else {
            $price = doubleval(substr($lowestPrice, 1)) * 100;
            $sql = "INSERT INTO items (marketName, avgPrice30Days) 
                    VALUES (:marketName, :avgPrice30Days)
                    ON DUPLICATE KEY UPDATE avgPrice30Days = :newPrice";
            $stmt = $db->prepare($sql);
            $stmt->bindValue(':marketName', $marketName);
            $stmt->bindValue(':avgPrice30Days', $price);
            $stmt->bindValue(':newPrice', $price);
            $stmt->execute();
        }

And truncate the price tables.

The reason for this is that the check-items works without a timestamp for example that means everytime the bot checks the price, it takes the price in the price table without asking questions, and if it doesnt exist it doesnt add it to the price table but simply return the price.

With this added code it will add the price into the price table instead of only returning the price if the item is non excitence :)

@Xeroner
Copy link
Author

Xeroner commented Dec 4, 2015

@Stuffa1991 script need to check first ,, if item exist do not insert but update ,,

@Stuffa1991
Copy link

Well the update part isnt actually supposed to be there, cause it will never occure, cause the script itself finds if the values exist and if it does it returns the price, therefore an update will never occure and is just there for no reason :D

@Xeroner
Copy link
Author

Xeroner commented Dec 4, 2015

But if table is empty? 💃

@Stuffa1991
Copy link

It will update the price only if the price is set to 0, else it will insert

As you can see ON DUPLICATE KEY UPDATE, means that if the thing it tries to insert is already there just update it instead, so its a sort of a fail safe for if the items that exist has a value of 0 :)

@Xeroner
Copy link
Author

Xeroner commented Dec 4, 2015

@Stuffa1991 you're right :)

@GreYzZ
Copy link

GreYzZ commented Jan 5, 2016

@Stuffa1991
The GoogleAuthenticator.php is not longer available, can you post it again?
Or create a new wiki page

@mx0c
Copy link

mx0c commented Jan 5, 2016

+1 Would be great!

@GreYzZ GreYzZ mentioned this issue Jan 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants