Giter Site home page Giter Site logo

Comments (5)

TwinkerMan avatar TwinkerMan commented on July 17, 2024

I just change "version" from 3 to 2 and add converting to 64 SteamID from 32 SteamID in POST data

data := map[string]string{
        "sessionid":                 c.sessionId,
        "serverid":                  "1",
        "partner":                   fmt.Sprintf("%d", other),
        "tradeoffermessage":         message,
        "json_tradeoffer":           string(jto),
        "captcha":                   "",
        "trade_offer_create_params": string(paramsJson),
    }

to

data := map[string]string{
        "sessionid":                 c.sessionId,
        "serverid":                  "1",
        "partner":                   fmt.Sprintf("%d", (((other.ToUint64() >> 1) * 2) + 76561197960265728)), // convert to 64SteamID
        "tradeoffermessage":         message,
        "json_tradeoffer":           string(jto),
        "captcha":                   "",
        "trade_offer_create_params": string(paramsJson),
    }

And now I can get resp.Body with content: http://i.imgur.com/nWiCkwX.png

from go-steam.

TwinkerMan avatar TwinkerMan commented on July 17, 2024

So nobody can't help me?

case *steam.WebLoggedOnEvent:
      log.Print("Successfully logged on web")

      token := "awajV_Bp"

      TOClient := tradeoffer.NewClient(SteamAPIKey, client.Web.SessionId, client.Web.SteamLogin, client.Web.SteamLoginSecure)

      myItems := make([]tradeoffer.TradeItem, 1)
      theirItems := make([]tradeoffer.TradeItem, 0)
      myItems[0] = tradeoffer.TradeItem{
        AppId: uint32(730),
        ContextId: uint64(2),
        Amount: uint(1),
        AssetId: uint64(there was CORRECT asset id),
      }
      SID, _ := steamid.NewId(there was account id)
      log.Println(TOClient.Create(SID, &token, myItems, theirItems, nil, ""))

Doesn't work too

from go-steam.

TwinkerMan avatar TwinkerMan commented on July 17, 2024

My own version of "create" function:

func (c *Client) Create(target steamid.SteamId, token string, myItems, theirItems []TradeItem, countered *TradeOfferId, message string) (*TradeCreateResult, error) {
    tradeoffer := map[string]interface{}{
        "newversion": true,
        "version": 2,
        "me": map[string]interface{}{
            "assets": myItems,
            "currency": make([]struct{}, 0),
            "ready": false,
        },
        "them": map[string]interface{}{
            "assets": theirItems,
            "currency": make([]struct{}, 0),
            "ready": false,
        },
    }

    jto, err := json.Marshal(tradeoffer)
    if err != nil {
        panic(err)
    }

    formFields := map[string]string{
        "serverid": "1",
        "sessionid": c.sessionId,
        "partner": target.ToString(),
        "tradeoffermessage": message,
        "json_tradeoffer": string(jto),
    }

    text, _ := json.Marshal(formFields)
    fmt.Println(string(text)) // Debug

    var referer string

    if countered != nil {
        referer = fmt.Sprintf("https://steamcommunity.com/tradeoffer/%d/", *countered)
        formFields["tradeofferid_countered"] = fmt.Sprintf("%d", *countered)
    } else {
        if (token != "") {
            params := make(map[string]string)
            if token != "" {
                params["trade_offer_access_token"] = token
            }

            paramsJson, err := json.Marshal(params)
            if err != nil {
                panic(err)
            }

            formFields["trade_offer_create_params"] = string(paramsJson)

            referer = "https://steamcommunity.com/tradeoffer/new/?partner="+strconv.FormatUint(uint64(target.GetAccountId()), 10)+"&token="+token
        } else {
            referer = "https://steamcommunity.com/tradeoffer/new/?partner="+strconv.FormatUint(uint64(target.GetAccountId()), 10)
        }
    }

    req := netutil.NewPostForm("https://steamcommunity.com/tradeoffer/new/send", netutil.ToUrlValues(formFields))
    req.Header.Add("Referer", referer)

    fmt.Println(req.Header) // Debug

    resp, err := c.client.Do(req)
    if err != nil {
        return nil, err
    }
    defer resp.Body.Close()

    // If we failed, error out
    if resp.StatusCode != 200 {
        fmt.Println("StatusCode", resp.StatusCode) // Debug
        data, _ := ioutil.ReadAll(resp.Body) // Debug
        fmt.Println(string(data)) // Debug

        return nil, errors.New("create error: status code not 200")
    }

    // Load the JSON result into TradeCreateResult
    result := new(TradeCreateResult)
    decoder := json.NewDecoder(resp.Body)
    decoder.Decode(result)
    return result, nil
}

and

case *steam.WebLoggedOnEvent:
      log.Print("Successfully logged on web")

      TOClient := tradeoffer.NewClient(SteamAPIKey, client.Web.SessionId, client.Web.SteamLogin, client.Web.SteamLoginSecure)

      myItems := make([]tradeoffer.TradeItem, 1)
      theirItems := make([]tradeoffer.TradeItem, 0)
      myItems[0] = tradeoffer.TradeItem{
        AppId: uint32(730),
        ContextId: uint64(2),
        Amount: uint(1),
        AssetId: uint64(there was CORRECT asset id),
      }
      SID, err := steamid.NewId(there was SteamID64)
      log.Println(err)

      log.Println(TOClient.Create(SID, "awajV_Bp", myItems, theirItems, nil, ""))

but it too returns

{"strError":"There was an error sending your trade offer.  Please try again later. (26)"}

from go-steam.

zhuharev avatar zhuharev commented on July 17, 2024

@TwinkerMan you resolve problem? May be you bot under defence SteamGuard?

from go-steam.

Philipp15b avatar Philipp15b commented on July 17, 2024

Closing due to unresponsiveness. Hopefully everything works OK now.

from go-steam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.