halipso / php-steam-tradeoffers

Steam Trade Offers for PHP (based on node.js library by Alex7Kom)
76 stars 31 forks source link

Internal Server 500 Error #17

Open sebastianlew opened 8 years ago

sebastianlew commented 8 years ago

Array ( [0] => HTTP/1.1 500 Internal Server Error [Server] => Apache [Vary] => Accept-Encoding,Origin [Content-Security-Policy] => script-src 'self' 'unsafe-inline' 'unsafe-eval' https://steamcommunity-a.akamaihd.net/ https://api.steampowered.com/ http://www.google-analytics.com https://ssl.google-analytics.com https://www.google.com https://www.gstatic.com https://apis.google.com; object-src 'none'; connect-src 'self' http://steamcommunity.com https://steamcommunity.com https://api.steampowered.com/; frame-src 'self' http://store.steampowered.com/ https://store.steampowered.com/ http://www.youtube.com https://www.youtube.com https://www.google.com; [Expires] => Mon, 26 Jul 1997 05:00:00 GMT [Cache-Control] => no-cache [Content-Length] => 89 [Content-Type] => application/json; charset=utf-8 [Date] => Mon, 15 Feb 2016 13:55:15 GMT [Connection] => close ) Error making offer! Server response code: 500

SzymonLisowiec commented 8 years ago

Hello, You give bad cookies for php-steam-tradeoffers.

2016-02-15 14:56 GMT+01:00 S3baso notifications@github.com:

Array ( [0] => HTTP/1.1 500 Internal Server Error [Server] => Apache [Vary] => Accept-Encoding,Origin [Content-Security-Policy] => script-src 'self' 'unsafe-inline' 'unsafe-eval' https://steamcommunity-a.akamaihd.net/ https://api.steampowered.com/ http://www.google-analytics.com https://ssl.google-analytics.com https://www.google.com https://www.gstatic.com https://apis.google.com; object-src 'none'; connect-src 'self' http://steamcommunity.com https://steamcommunity.com https://api.steampowered.com/; frame-src 'self' http://store.steampowered.com/ https://store.steampowe red.com/ https://store.steampowered.com/ http://www.youtube.com https://www.youtube.com https://www.google.com; [Expires] => Mon, 26 Jul 1997 05:00:00 GMT [Cache-Control] => no-cache [Content-Length] => 89 [Content-Type] => application/json; charset=utf-8 [Date] => Mon, 15 Feb 2016 13:55:15 GMT [Connection] => close ) Error making offer! Server response code: 500

— Reply to this email directly or view it on GitHub https://github.com/halipso/php-steam-tradeoffers/issues/17.

sebastianlew commented 8 years ago

HMM, i am using https://github.com/SzymonLisowiec/php-steamlogin is it correct ?

sebastianlew commented 8 years ago

Kurde.. Przeciez ty jestes polakiem. To jest moj kod ktory uzywam do logowania: //This is my code waht i am using to log in

$SteamLogin = new SteamLogin(array( 'username' => 'S3baso', 'password' => 'XXX', 'datapath' => dirname('cache')

)); if($SteamLogin->success){ $logindata = $SteamLogin->login('', $authcode);

//echo $SteamLogin->view('http://steamcommunity.com/id/pandeu'); $sessionId = $logindata['sessionId']; $cookies = $logindata['cookies'];

if($SteamLogin->error != '') echo $SteamLogin->error;

}else{ echo $SteamLogin->error; }

print_r($cookies); $steam = new SteamTrade(); $setup = $steam->setup( $sessionId, $cookies );

emdy commented 8 years ago

Hosting problem - change it Use http://mipropia.com/ as free host you can test, because host need to bee safe mode off because client cant reach the url

sebastianlew commented 8 years ago

Emm i think it isn't a problem. My host have safe mode off in php.ini

emdy commented 8 years ago

Its host certificate problem!

sebastianlew commented 8 years ago

Oh, okay, thank you mate for advice, i will try another host and i hope it'll help

emdy commented 8 years ago

@S3baso as i told just test on http://mipropia.com/ or use localhost

sebastianlew commented 8 years ago

mipropia.com throw me error 500, don't know why in php script. I'll just test it on localhost later.

emdy commented 8 years ago

USE IT MY FRIENDZONE require_once('classes/steam.class.php'); define('php-steamlogin', true); require('main.php');

$SteamLogin = new SteamLogin(array( 'username' => '**_', 'password' => '_', 'datapath' => dirname(FILE**) ));

if($SteamLogin->success){

$authcode = '*****'; $blank=''; $logindata = $SteamLogin->login($blank,$authcode); $login_values = array_values($logindata); //[1]=session, [2]=cookies $steam = new SteamTrade(); $steam->setup($login_values[1],$login_values[2]);

$them = [ [ "appid" => 730, "contextid" => "2", "amount" => 1, "assetid" => "4307137***" ]];

$result = $steam->makeOffer([ 'partnerSteamId' => 76561198035589***, 'itemsFromMe' => [], 'itemsFromThem' => $them ]); var_dump($result);

if($SteamLogin->error != '') echo $SteamLogin->error; }else{ echo $SteamLogin->error; }

sebastianlew commented 8 years ago

Look, it's your code: http://sebaso.mipropia.com/test.php

If i try to put in there manualy api key, i'm getting server response while making offer 401 (Unauthorized)

emdy commented 8 years ago

BECAUSE YOU NEED TO WHAIT 7 DAYS

tallesdantas commented 8 years ago

Same error , dont know whats wrong with my code , it loggs in , gets bot inventory, gets partner inventory but cant get own inventory , please emdy help =/

`$steam = new SteamTrade();

$steam->setup($session,$logindata['cookies']);

$INVENTORY = JSON_encode($steam->loadMyInventory([
'appId'=>$gameID
,'contextId'=>$igemContext
]));

//ECHO $INVENTORY;EXIT;

$PINVENTORY = JSON_encode(
$steam->loadPartnerInventory([
'partnerSteamId'=>'76561198048736485',
'appId'=>$gameID,
'contextId'=>$igemContext
]));

//echo $PINVENTORY;exit;

$tradeid = ([
    'partnerSteamId'=>'76561198061655090',
    'accessToken '=>'2gj7JSMf',
    'itemsFromMe'=>[],
    'itemsFromThem'=>[
        "appid" => $gameID,
        "contextid" => 2,
        "amount" => 1,
        "assetid" => "693235489",
    ],
    'message'=>'test trade '
]);

var_dump($steam->makeOffer($tradeid));
`
sebastianlew commented 8 years ago

I solved this problem. I wrote new code in php curl. I will send you here this for a minute. I am on phone now

tallesdantas commented 8 years ago

S3baso , please provide us your haalp >_<

sebastianlew commented 8 years ago

Oh sorry here is my function (not optimized) i wrote that in 15 minutes this code is ugly but works:

function makeOffer($sessionId, $cookies, $partner, $message = '', $token, $assetid) {
$type = 'POST';
$url = 'https://steamcommunity.com/tradeoffer/new/send';

$steamid = bcadd($partner, '76561197960265728');

    $data= array (
            'sessionid' => $sessionId,
            'serverid' => '1',
            'partner' => $steamid,
            'tradeoffermessage' => $message,
        'trade_offer_create_params' => '{"trade_offer_access_token": "'.$token.'"}',
            'json_tradeoffer' => '{"newversion":true,"version":2,"them":{"assets":[],"currency":[],"ready":false},"me":{"assets":[{"appid":730,"contextid":"2","amount":1,"assetid":"'.$assetid.'"}],"currency":[],"ready":false}}'
        );

        $c = curl_init();
        curl_setopt($c, CURLOPT_HEADER, false);
        curl_setopt($c, CURLOPT_NOBODY, false);
        curl_setopt($c, CURLOPT_URL, $url);
        curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)");
        curl_setopt($c, CURLOPT_COOKIE, $cookies);
        curl_setopt($c, CURLOPT_POST, 1);
        curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($data));
        curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($c, CURLOPT_HTTPHEADER, array('Referer: https://steamcommunity.com/tradeoffer/new/?partner='.$partner.'&token='.$token));
        curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($c, CURLOPT_CUSTOMREQUEST, strtoupper($type));
        $return = curl_exec($c);
        curl_close($c);

return $return;
}

Use:

echo makeOffer($sessionId, $cookies, $partner, $message = '', $token, $assetid);

$sessionId = session ID of actually logged in user $cookies = cookies of actually logged in user $partner = partner from trade link (for example trade link: https://steamcommunity.com/tradeoffer/new/?partner=191983333&token=K13zBHQ5 --- partner for that is 191983333) $message = message for your offer (not required) $token = is token from trade link (for example: https://steamcommunity.com/tradeoffer/new/?partner=191983333&token=K13zBHQ5 -- token is K13zBHQ5) $assetid = asset ID of item you want to send offer

P.S. Sorry for my bad english :-1:

sebastianlew commented 8 years ago

Oh, you wanted load your own inventory..

$items = $steam ->loadMyInventory(array(
    'appId' => '730',
    'contextId' => '2',
    'language' => 'polish'
));

foreach($items as $data) {
var_dump($data);
}

For me works perfect. I hadn't problem with that

tallesdantas commented 8 years ago

Thanks S3baso , will try your code soon , really thanks =D you saved my day o/

sebastianlew commented 8 years ago

No problem, i had same problem few days ago. So i really understand you :D

tallesdantas commented 8 years ago

S3baso , by the way , how do you confirm steam bot trade trought mobile auth? i know i will face this problem soon , i'm able to generate the Code to loging like the mobile one, but i dont know how to simmulate the confirmation can you help?

sebastianlew commented 8 years ago

You need shared secret code (i exported that code from my app on phone). Search in google how to export shared secret code from your phone, then i will help you.

tallesdantas commented 8 years ago

I have it already o/ , can you add me on steam?

http://steamcommunity.com/profiles/76561198048736485/

emdy commented 8 years ago

@S3baso what cind of link u use to manipulate with trade accept?

sebastianlew commented 8 years ago

https://steamcommunity.com/mobileconf/conf?p=android:{YOUR_DEVICE_ID}&a={STEAM_ID}&k={AUTH_KEY}&t=1447961491&m=android&tag=conf

emdy commented 8 years ago

@S3baso u use SDK or like root app to view values?

sebastianlew commented 8 years ago

Only php, but this code took me weeks..

emdy commented 8 years ago

I rooted my phone and am done yet ;)

emdy commented 8 years ago

@S3baso author key is simple author code 5dig and t is trade Id,ye?

sebastianlew commented 8 years ago

not really, you must get from that confirmation key, and confirmation id. Then use

https://steamcommunity.com/mobileconf/ajaxop?op=allow&p=android:{YOUR_DEVICE_ID}&a={STEAM_ID}&k={AUTH_KEY}&t={STEAM_TIME}&m=android&tag=allow&cid={CONFIRMATION_ID}&ck={CONFIRMATION_KEY}

emdy commented 8 years ago

@S3baso you tested to confirm trades, work?

sebastianlew commented 8 years ago

I will put my script to github later.

emdy commented 8 years ago

I get this urls from webcache but i have no idea what time you need to put, becase i get oops error so..

timmy78 commented 8 years ago

@S3baso Thank you for code example, it works fine !

So I don't understand why the function makeOffer doesn't work. I have an error 411 ?! If I add a "Content-Length" ($headers['Content-Length'] = 3495; at line 218), I have now a timeout : "Operation timed out after 5000 milliseconds with 0 bytes received".

Am I the only one ??

sebastianlew commented 8 years ago

Are you sure that cookies are correct? Try to print response from curl and paste it here

sebastianlew commented 8 years ago

Cookies must have SteamLogin, SteamMachineAuth, sessionid and something else but i don't remember. Can you paste variables from cookies what you have?

timmy78 commented 8 years ago

@S3baso You ask to me ?

sebastianlew commented 8 years ago

Yes, you said that you have error 411 right?

timmy78 commented 8 years ago

@S3baso Yes, but my cookies and sessionId are correct because it works with your code .

sebastianlew commented 8 years ago

So my code is working correct? You had error with halipso php tradeoffers yes?

timmy78 commented 8 years ago

@S3baso Yes your wode works fine, but the code of this library doesn't work for me :wink:

sebastianlew commented 8 years ago

Oh, okay. I think we all have problem with this library

emdy commented 8 years ago

Its lib problem because http simple dom is missing some headers, use @Sbaso code - its same as php-tradeoffers!!!

emdy commented 8 years ago

Root your phone or use SDK to get device id and other stuff.

timmy78 commented 8 years ago

Oh no, it was my fault, I had replaced all the URL https://steamcommunity.com by http://steamcommunity.com :confused: . I removed this change and it works fine now :smile:

amaraa019 commented 8 years ago

steam.class.php in replace all timeout(5) to timeout(30) (Operation timed out after 5000 milliseconds with 0 bytes received) it will disappear. if your steam.class.php use https increase timeout function's argument

Govind13100 commented 7 years ago

@S3baso Hie there, I have tried your makeoffer() function , returning "null" :-(

I have passed all the parameter correctly>

Can you please suggest me any thing ?????

Any help would be very great!!!

emdy commented 7 years ago

Start and check login status, itemid, tradeurl, mby itemid is inactive etc. more stuff that causes null

Govind13100 commented 7 years ago

I checked all the parameters, I tried cookies by logging in manually into steam account and got the cookies and session id from browser settings. I also tired your login script to get all cookies and session id and then passed it to the makeoffer(). Still Null :-(

Yesterday when i run this makeoffer() its returns null on live server, and on localhost it returns

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

You have logged in from a new device. In order to protect the items in your inventory, you will be unable to trade from this device for 7 days."}

From this error i understand the there is a parameter in inventory json called "market_tradeable_restrictons:7" this means i can trade my item after 7 days.

But now when i again hit the url on localhost, this time it returns null, I am so very confused about all this.

emdy commented 7 years ago

If your not new in php i suggest export curl and test it, because Iam sure than you missing some attribute

Govind13100 commented 7 years ago
$sessionId  = 'c65a62c35ff42f409b98dbf30d';
$cookies = 'steamCountry=US%7Cbdfba7df0d61cb192e69ad96beb42e635,steamLogin=76561197960912172%7C%7C84838E49336D76A77E2D351FBD6B7CB90D7DAE53, steamLoginSecure=7656119796ff0912172%7C%7C4EFE85A64073548BB93f925AE4052C9C2062BB323,steamMachineAuth76561197960912172=24300302D710425B41D4f7272975FAF204E977039, steamRememberLogin=76561197960912172%7C%7Cc0daf33cffb175964e11d20dd0a163849,sessionid=c65a62c3542f409b98dbf30d'; 
$partner = '424253243';
$token = 'Iqz42WHn';
$assetid = '10546157324';

echo makeOffer($sessionId, $cookies, $partner, $message = '', $token, $assetid);

function makeOffer($sessionId, $cookies, $partner, $message = '', $token, $assetid) {
$type = 'POST';
$url = 'https://steamcommunity.com/tradeoffer/new/send';

$steamid = bcadd($partner, '76561198384518971');

    $data= array (
            'sessionid' => $sessionId,
            'serverid' => '1',
            'partner' => $steamid,
            'tradeoffermessage' => $message,
        'trade_offer_create_params' => '{"trade_offer_access_token": "'.$token.'"}',
            'json_tradeoffer' => '{"newversion":true,"version":2,"them":{"assets":[],"currency":[],"ready":false},"me":{"assets":[{"appid":730,"contextid":"2","amount":1,"assetid":"'.$assetid.'"}],"currency":[],"ready":false}}'
        );

        $c = curl_init();
        curl_setopt($c, CURLOPT_HEADER, false);
        curl_setopt($c, CURLOPT_NOBODY, false);
        curl_setopt($c, CURLOPT_URL, $url);
        curl_setopt($c, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($c, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)");
        curl_setopt($c, CURLOPT_COOKIE, $cookies);
        curl_setopt($c, CURLOPT_POST, 1);
        curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($data));
        curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($c, CURLOPT_HTTPHEADER, array('Referer: https://steamcommunity.com/tradeoffer/new/?partner='.$partner.'&token='.$token));
        curl_setopt($c, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($c, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($c, CURLOPT_CUSTOMREQUEST, strtoupper($type));
        $return = curl_exec($c);
        curl_close($c);

return $return;

This is my code and i tried many combinations with sessionid and cookies

Got the sessionid and cookies from your login script which you provided us

Got the sessionid and cookies from browser setting

By market_tradeable_restriction for 7days(because of new device login) , I have also tried this code on old device but still same negative result.

but i am still unable to get the positive result, it always returned null or sometimes a blank page, I don't know what I am missing ???

I am asking you because i tried many thing and still got nothing.

If you could help me out here by looking at my code then it would be very greatful ..

Thanks in advance!!!!!!