How can I send trade offer
Asked Answered
K

3

6

Actually I am working on Steam trade offer functionality, in which I am getting a problem. I have downloaded the Steam class library and implement it in Codeigniter. I am following the setup guide from https://github.com/halipso/php-steam-tradeoffers#setupsessionid-cookies this. Actually I don't know about session id and cookie:

$steam->setup('sessionID', 'cookies');

What will be sessionID and cookies?

I have read about it but did not get any solution. How can I get and implement it in my code?

Kumkumagai answered 9/11, 2017 at 7:51 Comment(1)
Is there any one who can help me?Kumkumagai
M
3

Well if this is on Laravel you can send _token which call as csrf_field by them.


In CI you can do like this. (csrf generate unique session id)

Path - application/config/config.php

$config['csrf_protection'] = TRUE;

In Login form, you can add this or in page initialize you can add this

$csrf = array(
        'name' => $this->security->get_csrf_token_name(),
        'hash' => $this->security->get_csrf_hash()
);

<input type="hidden" name="<?=$csrf['name'];?>" value="<?=$csrf['hash'];?>" />

So when saving you can add this to the session. BTW this token can use for cookie as well.

Read this Cross-site request forgery (CSRF)

Tokens may be either regenerated on every submission (default) or kept the same throughout the life of the CSRF cookie. The default regeneration of tokens provides stricter security, but may result in usability concerns as other tokens become invalid (back/forward navigation, multiple tabs/windows, asynchronous actions, etc). You may alter this behavior by editing the following config parameter

Source Codeigniter documentation


If it's not in a login page, then

Its better to se this false,(due to this Tokens may be either regenerated on every submission (default))

$config['csrf_regenerate'] = FALSE;
Mosier answered 15/11, 2017 at 15:27 Comment(0)
S
2

The session ID is the UUID of Steam which corresponds to our Steam profile. The cookies are there to keep you authenticate.

Here's an example how you can get the sessionID and the cookies : https://github.com/SzymonLisowiec/php-steamlogin (not my repo, credit to SzymonLisowiec)

Stander answered 14/11, 2017 at 7:29 Comment(7)
Thanks for your reply.I have implement this code but still I am not able to get cookie, because there is cookiejar.txt file is missing. Do you have any idea?Kumkumagai
I didn't tested it myself. From the issues, it say datapath must have chmod 777 because Curl is creating the file cookiejar.txt in it. But keep in mind that chmod 777 is too permissive for a production environment.Orgiastic
Okay,thanks now it is working. But still my work in incomplete due to invalid response. I am follow this but result is showing me Invalid response $invent = array( 'contextId' => 2, 'appId' => 730); $result = $steam->loadMyInventory($invent); echo $result;Kumkumagai
Any SuggestionsKumkumagai
Can you, please, provide more detail?Orgiastic
okay. I want to load my partner inventory. My code is $partnerinventorydata = array( 'partnerSteamId' => '76561198345631230', 'appId' => '730', 'contextId'=>'2', 'tradeOfferId'=>true, 'language'=>'english' ); $getpartnerInventoryData=$steam->loadPartnerInventory($partnerinventorydata); print_r($getpartnerInventoryData); Giving me Invalid ResponseKumkumagai
Let us continue this discussion in chat.Kumkumagai
K
2

First of all the documentation at doc says that you only need a API KEY in order to send the requests and calls to endpoint, for the class library you are using have helped you from going into your account and getting API KEY yourself.
so by examining class SteamTrade would explain setup(sessionId, cookies):

  1. if have API KEY then I don't need Cookies and SessionID stop else go step 2.
  2. get API KEY but you should provide me with Cookies and sessionid in order for me to login and accept agreement and register your account as developer account go step 1 else show error .


Note: all calls done with this format no need for SessionID and Cookies only if not provide API KEY.

http://api.steampowered.com/interface-name/method-name/version/?key=apikey&format=format.
Screenshot:
show how to grab sessionid and cookies with firefox inspector cookies tab

sessionid screenshot

Kordofanian answered 20/11, 2017 at 15:14 Comment(2)
thanks for your reply. I got already session id and cookies but still I am facing "Invalid Response" error. For example I am calling $partnerinventorydata = array( 'partnerSteamId' => '76561198345631230', 'appId' => '730', 'contextId'=>'2', 'tradeOfferId'=>true, 'language'=>'english' ); $getpartnerInventoryData=$steam->loadPartnerInventory($partn‌​erinventorydata); print_r($getpartnerInventoryData); Then it is giving me invalid response error. Can you help for this error.Kumkumagai
first you have to verified that the API KEY have been set ! also can provide the full response by editing the class to return the response information.Kordofanian

© 2022 - 2024 — McMap. All rights reserved.