Steam - 如果用户已登录,则此页面可用。 如何用PHP获取它?

This is my first question here :)

I have on my mind a little feature for my website. And I am trying to find a way how to do it.

If user is logged in on Steam, he can access this page: http://store.steampowered.com/dynamicstore/userdata/?id=STEAMID

and it contains information about his wishlist and owned games.

Result for logged user:

{"rgWishlist":[500,1300,1620,7020,8340,8870,8980,9350,10090,10130,10400,10680,12200,16600,17580,22320,24780,28000,32160,33990,39000,42170,42700,45710,49540,50130,51100,55000,65710,96800,102500,102810,105600,110800,113020,113400,115320,200490,202310,204030,204080,204530,205100,207000,208200,208670,209060,209160,211420,211820,212480,213670,214250,218230,219740,219990,220200,221100,223430,223710,224260,225540,225840,227300,228300,228380,228760,229580,230840,231200,231430,232090,233370,233450,233610,233720,234080,235460,235800,236370,238960,239140,239820,239840,240760,241930,242050,242550,242760,242840,244030,244160,244210,244910,245490,247730,248860,249380,250520,250620,251110,251170,251490,251570,251850,252490,255220,256290,256390,257790,258180,260230,261530,261570,261740,262060,263760,265950,266330,267060,269030,269350,269650,271590,272920,273110,274190,274520,275100,275850,278440,281690,281840,281940,282070,282140,284160,285900,286540,286570,287700,287980,288260,289070,290060,290790,290930,292730,293340,293460,293520,293740,293760,294860,296550,296710,298110,298900,300380,301520,301860,303430,303940,304390,304650,304930,305620,306760,307780,310510,311210,312530,313630,314280,315440,317100,318230,319450,321370,321450,321560,322680,325520,326120,327060,327560,327740,327860,327890,328070,329430,330770,331120,331450,332200,334230,334780,335560,337000,339850,340490,341800,341950,343780,344480,346010,346440,346610,348030,352950,356180,357600,358040,359840,360430,361550,362680,365160,365590,368360,373180,373420,374410,375820,375900,378610,379430,380150,381210,383870,384000,384110,384190,387290,388880,391040,391220,392000,395200,396750,396900,399780,399820,400360,402710,402840,405820,405950,408650,408920,414510,415200,416550,417880,418240,419460,420570,424840,426170,427520,431600,431650,432720,433850,436110,437350,439550,442780,444560,444580,446750,449330,457210,457760,457860,460920,461840,462030,463210,474960,480490,481110,485860,489830,497700,498330,501300,505630,507010,512790,513300,513570,524220,530890,537050,567320,580200,582270,612570,660990,433340,414340,441790,506900,350280,386180],"rgOwnedPackages":[418,34,482,20,7877,12762,8312,11183,13533,14870,15740,14361,17250,18029,13503,14559,7970,8386,4821,13743,1845,1062,15756,599,2788,14906,2075,15185,15731,11838,18011,14603,8882,12129,7968,8546,13883,14759,16805,4109,27566,17933,28315,40,636,6497,14997,17948,14367,13379,18369,11072,19223,27546,6516,6749,13452,1472,531,1484,13046,15157,11698,7479,2015,13436,17638,2109,2644,8861,11746,12382,987,25544,27973,11734,14842,7978,17423,1235,1290,461,25926,4776,12225,1679,30200,2208,30191,30192,6183,402,27106,25939,7209,11071,8451,904,26550,27495,30323,12339,25526,17641,27035,32889,18485,12328,216,36144,30701,31060,29006,17880,30352,30170,36483,44417,34369,26358,29976,28999,30960,43996,45063,45074,32887,45658,45585,25882,8314,33374,27237,38506,1259,29616,42634,30888,33977,30939,17038,1505,11112,47182,34149,47066,1214,2030,38928,32861,20944,20945,6822,45159,45071,21112,21065,47235,16631,21042,7944,21158,39544,16986,27276,38853,47987,2355,2658,30306,41229,21293,40847,21430,30750,34200,20671,21387,19074,38595,52998,21492,48830,51336,33201,50323,48754,7490,30891,41485,41464,43316,53602,38036,44220,56067,29360,39531,8562,13895,17516,33817,1493,20857,21250,43355,37194,4160,30043,37191,55568,7416,15142,42858,36422,11687,34774,44751,35502,49587,53296,21199,59107,14729,46804,68160,29727,47245,13754,37993,27238,69126,39303,40957,57082,55943,32263,39667,45469,43616,25839,52512,41626,43922,40470,1488,8173,34879,48074,14795,46786,43386,614,41220,21423,66255,20905,48765,21395,74706,72493,50278,28545,57715,49943,43349,42586,30256,26495,31185,38265,21031,1422,78237,75178,37393,59789,8198,298,68091,21443,32133,42580,78252,40158,39637,40523,52089,12028,29884,40679,84435,68051,75585,57795,21076,34665,76474,4549,56694,40537,66920,51051,1056,1494,29907,18867,35545,34780,61597,56218,74609,35574,42970,17631,44452,72760,82581,60018,81134,91381,91032,20872,59490,64160,21245,62974,71743,58391,38335,39269,56669,1515,33052,42816,65491,75919,29526,47927,55940,94153,35794,62725,94160,20783,94161,70369,21270,51117,93621,93537,31131,39922,28540,95395,67756,549,88108,51069,76039,21259,76757,65013,21408,20923,77600,33076,34759,8560,55793,56461,77649,42991,38001,27835,16092,73534,49661,65172,41226,30371,29890,46469,40685,26901,59341,6148,20947,20729,20932,17888,61576,34329,40817,27263,34807,40772,13568,56358,49122,8716,28816,34170,35704,13646,29855,30542,31565,30377,28955,32308,33113,15003,30792,34134,35746,46180,46824,53158,28931,32061,34822,26183,13989,30999,17172,26266,12456,15055,1465,14840,4819,11611,28596,18265,26375,16699,7706,16640,16767,15919,27322,17607,18769,15136,13616,16586,14909,97595,33677,59012,49741,2047,15979,1942,100703,88321,75916,82563,33064,72664,93613,27812,37103,49673,21409,20786,55353,47144,39996,48123,14290,64995,64820,72610,56926,12152,30948,8049,38214,37402,42474,77425,34795,28021,41068,38559,55062,547,40476,28097,28927,106060,15205,27293,89667,100138,34022,702,37125,64451,72593,14193,30251,39982,38271,48191,38268,51424,54949,64412,89925,34599,25743,16204,50909,76384,89803,1170,6124,67169,29165,29905,45549,59469,1405,50205,98632,42792,82994,39442,37433,35891,34088,26984,14205,30918,103508,11684,15568,31119,35084,41578,109048,102336,87910,20766,65888,30855,35824,51178,43782,46023,39171,79937,84065,53277,61381,56276,21444,54377,14683,48958,33832,35896,26445,45725,28788,95455,96800,107116,63925,75379,80561,41717,8533,114751,33177,64212,35999,54361,21087,50492,111285,49753,80664,76760,82080,52656,18362,119931,105607,34861,59177,102519,21362,12542,17697,63041,33604,31087,27400,26778,13165,28514,43899,45976,50844,29391,34269,78571,54017,33498,18063,76477,20986,127006,130344,133966,50695,43773,88823,79399,50167,102507,86784,29509,82715,58383,44663,273,2702,34251,63907,40284,51421,56792,39499,140321,96590,102996,75922,67694,66026,30765,1769,32765,29048,16892,17322,79659,72683,64541,46905,44607,44739,63618,51418,1386,18047,18050,18051,342,11381,63651,49213,38250,33570,52402,72129,31384,47261,72317,50054,35501,50489,45882,30674,49566,117654,11840,63723,75794,41691,57566,133704,16377,134394,35680,15015,51504,43679,78524,64454,7342,40572,96490,53493,86904,38650,80233,2314,6181,20718,20719,147541,100846,131135,53724,13756,50820,42551,35390,41177,8433,98503,40612,30287,27780,151940,45279,87688,118580,34641,50666,8566,8567,82524,73787,18120,134418,7117,73321,112932,54903,37197,61123,34140,152198,161693,56219,63678,50518,88364,46564,45025,116814,65168,103951,119309,35779,105083,149433,117118,29074,126197,54785,96879,119495,77126,50061,101220,15982,6268,65482,67159,76287,73562,11630,157210,168670,164638,133592,165210,159761,152127,34647,102184,69982,85370,143378,140189,95795,94270,74780,114373,68925,130669,101362,44120,33915,117460,39430,46156,52167,50578,152112,179323,27708,38760,33912,115225,39439,38778,107027,39253,105530,139324,55366,42837,48889,52894,31558,29888,114054,182905,183411,149204,34128,6888,64005,44117,32284,111470,69092,30499,6646,55616,76705,88533,38297,38991,16332,68569,79686,112110,72402,29168,28499,77567,21115,103386,101060,74150,141611,147048,59621,36558,87427,0,190219,41312,131680,194057,76668,32278,151924,143440,18575,107528,53656,62651,126818,68094,4113,8558,90085,43296,976,52490,8559,119722,11376,58985,141524,7377,99158,55985,34933,12100,65033,61326,116031,196877,96084,77742,172509,31128,85099,76124,174698,29760,31047,6637,84755,74493,84005,146690,129415,73454,38495,118674,165909,48282,201157,52757],"rgOwnedApps":[10,20,30,40,50,60,70,80,100,130,220,320,340,360,364,380,400,420,440,459,520,550,564,570,575,620,730,1250,1255,1500,1510,1520,1530,2270,2400,2420,2430,2500,2590,2800,2810,2820,2840,2850,2990,3020,3700,3730,3830,3840,4000,4500,4540,4550,4560,4720,4760,4800,4920,6880,7000,7510,7520,7670,7760,7860,8000,8140,8190,8600,8790,8930,9000,9010,9200,9241,9480,11020,11050,11180,11190,11240,11280,11330,11340,11360,11370,11390,11420,12130,12210,12220,12310,12390,12750,12900,15120,15560,16450,16720,16730,16860,16861,16862,16863,16864,16865,16866,16867,16868,16870,16871,17080,17300,17330,17340,17410,17450,17460,17470,17570,17710,18300,18500,18507,18820,19200,19680,21010,21100,22100,22200,22230,22330,22333,22370,22490,22610,22641,22650,22670,23300,23310,23380,23460,23490,24240,24420,24740,24800,24936,24939,27000,27900,28050,28060,28061,29130,29800,31280,32360,32370,32460,32800,33100,34270,34276,34490,34491,34492,34493,34494,34495,34496,34497,34498,34870,34900,35080,35083,35086,35087,35089,35090,35091,35093,35094,35095,35096,35097,35098,35101,35102,35130,35134,35137,35140,35320,35420,35428,35450,35700,35720,35725,38210,38220,38720,38740,39160,39190,40300,40390,40391,40392,40393,40800,41070,41500,42500,42910,42914,42918,43000,43012,43110,44620,44630,44650,44660,44670,44680,44690,45410,45450,46250,46410,46440,46450,46460,46500,46510,46520,47790,47799,47830,47843,48000,50300,50620,55100,55110,55113,55114,55115,55230,55380,55381,55382,55385,55386,55387,55388,55389,55390,55391,55392,55395,55396,55397,55398,55399,55400,57300,57640,57680,57690,57900,57925,61310,63000,63003,63004,63380,65790,67370,71115,71117,71120,71165,72701,72705,72709,72713,72770,72771,72772,72773,72774,72850,73032,73115,91100,91310,91342,91345,91346,91600,91604,91605,91606,91607,91608,91612,91613,91614,91615,91617,91618,92000,92100,92400,92600,92620,92621,92622,94400,95000,95300,96000,97000,98100,98200,98400,98421,98500,99300,99610,99611,99612,99613,99614,99700,102000,102001,102002,102003,102029,102600,102621,102622,102623,104200,105000,105300,107100,108100,108710,108726,108800,110400,113200,113204,113205,115110,116100,200010,200230,200260,200269,200390,200396,200397,200410,200510,200519,200610,200620,200730,201280,201310,201700,201790,201801,201802,201804,201805,201810,202750,203160,203180,203230,203250,203730,203750,203810,203830,204060,204075,204100,204112,204180,204240,204300,204450,204470,204482,204483,204630,204900,204901,204902,205230,205350,205730,205790,205870,205910,205950,206190,206524,207020,207040,207140,207570,207610,207690,208140,208157,208500,208600,208610,208750,208790,208791,208792,208793,208795,208796,208797,208798,208799,208800,208806,208807,208808,208809,208810,208811,208812,208813,208814,208817,208818,209190,209230,209771,209772,209790,209819,210150,210170,210450,210770,210934,210936,210942,210943,210950,210970,211050,211160,211280,211400,212050,212780,213311,213312,214150,214190,214340,214360,214420,214490,214550,214970,215530,215550,215630,216110,217100,217690,217920,218510,218620,218640,219150,219640,219680,219890,219910,220160,220440,220460,220740,220780,220820,220860,220900,221260,221640,221910,222730,222880,222890,223220,223530,224220,224960,225080,225300,225320,225360,225420,227080,227220,227280,227480,228200,228221,228400,229330,229810,229870,230190,230820,230886,231020,231040,231160,231330,232430,232644,232750,233130,233230,233250,233290,233432,233550,233740,234140,234190,234510,234570,234630,234650,234940,235210,235250,235720,235820,236150,237110,237350,238320,238430,238460,238910,239200,239430,241240,241320,241430,241910,242780,242880,243120,243200,243450,244630,244690,244710,244730,244870,245150,245170,245280,246420,246620,246700,246900,247020,247950,248190,248470,248490,248530,248550,248570,248610,248710,248730,248820,248970,249050,249230,249650,249680,249700,249990,250030,250400,250580,251130,251310,251630,251730,251910,252330,252550,252570,252750,252850,252890,252950,253030,253290,253610,253690,253900,253960,253980,254260,254420,254421,254422,254423,254440,255280,255300,255320,255520,256190,257120,257510,257750,257850,257890,258050,258520,258543,258751,258890,258950,259470,259550,259600,259830,261110,261160,261161,261180,261680,261760,262260,262280,262390,262410,262690,262940,263020,263280,263320,263360,263420,263560,263740,264080,264120,264200,264240,264520,264730,265210,265300,265330,265380,265690,265790,265830,265930,266010,266110,266370,266490,267381,267580,267660,267960,268081,268320,268540,269050,269210,269490,269710,269810,270010,270450,270490,270550,270850,271240,271570,271750,271840,272040,272350,273840,274290,274500,274880,274900,274920,275470,275530,275670,278360,278570,279110,279111,279112,279260,279440,279540,279560,279580,279720,279920,280740,280830,280910,281280,281410,281990,282440,282760,283180,284240,284460,284930,284990,285010,285330,285500,285580,285840,286040,287100,287340,287390,288160,288650,289280,289320,289600,289730,289731,289733,289734,289760,290280,290320,290770,291070,291270,291480,291550,291610,291650,292410,292570,292600,292620,293180,293320,293940,294230,295250,295530,295690,295730,295790,296050,296470,296630,296770,296910,297350,297490,298140,298260,298480,298520,298810,299170,299460,300060,300580,301190,301200,301480,301910,302130,302510,302710,303210,303390,303470,304240,304430,305050,305380,306410,307010,307550,307580,307880,308420,308580,310070,310560,311250,311340,311480,311730,311820,312960,312990,313070,313080,313250,314710,315060,315260,315430,315600,316010,316670,317360,317400,317440,317710,318220,318940,319480,319550,319630,319910,320140,320540,320820,320840,321040,321150,321480,321620,321920,322022,322190,322500,322970,323060,323320,323580,323720,324060,324070,324750,324760,324770,324810,325060,325090,325462,326190,326410,327090,327270,327410,328600,328820,328821,329370,329770,329830,330450,330830,331710,332500,332580,333650,333930,334070,334770,335240,335300,336030,337040,337960,338140,338320,338550,339400,339790,340280,342300,342580,343710,343740,344510,345130,345220,345390,345520,345700,346180,346560,346950,347430,347440,350470,351030,351510,351740,352520,354850,355590,355740,355760,356570,358270,358380,358470,358640,359060,359350,359800,359960,360520,360640,360650,360940,361700,361710,361720,361730,361740,361750,361760,361770,361780,362180,362190,362200,362210,362220,362230,362240,362250,362260,362270,362280,362410,362890,363940,363970,365300,365770,365940,367580,368010,368230,368370,368730,368870,368900,369180,370360,371330,371400,371500,371510,372900,373550,373551,373990,374353,374354,374460,374570,377120,377160,378490,379720,381120,382490,383790,384250,384310,384570,385200,385270,385490,385560,385720,385760,385770,387985,387986,387987,388050,388420,389190,389590,389591,390040,390340,390570,390910,391270,391540,391720,392020,393650,394760,395150,395160,395170,395860,395980,396030,396530,396790,396800,397060,397340,397620,398850,399670,400110,400250,400370,400430,400630,402330,402570,404700,405500,405530,406150,406220,406940,407840,408120,408370,408600,409710,410590,411560,412880,412940,413160,413850,413851,413852,413853,413854,413855,413856,413857,413858,413859,416270,416610,416770,417860,418610,419500,420000,422970,425580,426290,427270,427780,428420,429180,431270,431560,432020,432150,432470,432950,437570,441650,441870,443080,443810,446870,447850,447880,448510,449760,450050,450130,450590,450670,452640,455400,455470,456470,456480,458250,458260,458270,458280,458300,458310,458320,459910,461070,461910,462270,462370,462780,463150,465520,465930,466500,469010,469820,470260,473090,473530,475150,478330,479170,481380,481830,484910,484920,489520,491130,491390,491830,492690,493280,493530,495460,495470,496300,497810,497811,497812,497813,498320,498660,499520,501690,502490,503110,503590,505430,506590,507490,508740,509430,510590,510850,511310,512300,513550,516700,520720,526790,528300,531810,532000,533240,533860,537324,537560,538590,554350,559500,561522,561530,561531,561552,562800,564310,564323,567090,567290,573230,573920,575630,576740,577401,581700,583190,585280,585281,585282,585283,587650,588430,600420,606730,612560,618310,624820,633130,635640,635880,645970],"rgPackagesInCart":[],"rgAppsInCart":[],"rgRecommendedTags":[{"tagid":3835,"name":"Post-apokalyptick\u00e9"},{"tagid":1695,"name":"S otev\u0159en\u00fdm sv\u011btem"},{"tagid":4182,"name":"Pro jednoho hr\u00e1\u010de"},{"tagid":3834,"name":"S pr\u016fzkumem prost\u0159ed\u00ed"},{"tagid":19,"name":"Ak\u010dn\u00ed"},{"tagid":1774,"name":"St\u0159\u00edle\u010dky"},{"tagid":1663,"name":"FPS"},{"tagid":122,"name":"RPG"},{"tagid":492,"name":"Nez\u00e1visl\u00e9"},{"tagid":21,"name":"Dobrodru\u017en\u00e9"},{"tagid":4166,"name":"Atmosferick\u00e9"},{"tagid":3839,"name":"Z pohledu prvn\u00ed osoby"},{"tagid":597,"name":"Nen\u00e1ro\u010dn\u00e9"},{"tagid":1742,"name":"S bohat\u00fdm p\u0159\u00edb\u011bhem"},{"tagid":3859,"name":"Pro v\u00edce hr\u00e1\u010d\u016f"},{"tagid":3942,"name":"Sci-fi"},{"tagid":1756,"name":"S v\u00fdborn\u00fdm soundtrackem"},{"tagid":4231,"name":"Ak\u010dn\u00ed RPG"},{"tagid":1697,"name":"Z pohledu t\u0159et\u00ed osoby"},{"tagid":3810,"name":"Sandboxov\u00e9"}],"rgIgnoredApps":[],"rgIgnoredPackages":[]}

I would like to access this page, but if I try to access it via PHP, it's empty (no valuable information).

Result without being logged in:

{"rgWishlist":[],"rgOwnedPackages":[],"rgOwnedApps":[],"rgPackagesInCart":[],"rgAppsInCart":[],"rgRecommendedTags":[{"tagid":492,"name":"Nez\u00e1visl\u00e9"},{"tagid":19,"name":"Ak\u010dn\u00ed"},{"tagid":21,"name":"Dobrodru\u017en\u00e9"},{"tagid":597,"name":"Nen\u00e1ro\u010dn\u00e9"},{"tagid":9,"name":"Strategick\u00e9"},{"tagid":599,"name":"Simulace"},{"tagid":122,"name":"RPG"},{"tagid":113,"name":"Free to play"},{"tagid":4182,"name":"Pro jednoho hr\u00e1\u010de"},{"tagid":128,"name":"Masivn\u011b multiplayerov\u00e9"}],"rgIgnoredApps":[],"rgIgnoredPackages":[]}

I read that it may be possible with cURL, but I didn't find a way to do it.

My plan so far is to create a link on my website. If user clicks, he is shown content of the Steam page and he has to copy all of it to a form and send it. It works, but it is complicated for the user.

Is there any trick to do it? Or is it considered unsafe and "hacking"?

I tried to use file_get_contents() and also this:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://store.steampowered.com/dynamicstore/userdata/?id=STEAMID");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
doubi4814
doubi4814 蒸汽落后于API。你也可以将API-Key作为参数发送。
大约 3 年之前 回复
douzhi1924
douzhi1924 我添加了你要求的内容。我希望这样好。
大约 3 年之前 回复
dpppic5186
dpppic5186 您可以编辑您的问题,添加1-您的代码和2-您从中获得的结果,以便我们更好地帮助您?:-)
大约 3 年之前 回复

1个回答




我想访问此页面,但如果我尝试通过PHP访问它,它就是空的(没有价值 信息)。 </ p>
</ blockquote>

正确 - 因为您的PHP脚本在注销时正在访问该页面。 通过浏览器登录的用户不会“继承”PHP脚本发出的请求。</ p>

不太可能从PHP脚本发出登录请求; 它要求用户为您的网站提供他们的Steam用户名,密码和一次性登录令牌。 (当然,从安全角度来看,这是一个糟糕的想法。不要这样做。)</ p>

除非Steam有其他API来访问这些数据,否则您所描述的解决方案 (手动复制/粘贴)可能是您唯一的选择。</ p>
</ div>

展开原文

原文

I would like to access this page, but if I try to access it via PHP, it's empty (no valuable information).

Right -- because your PHP script is accessing the page while logged out. The user being logged in through their browser doesn't "carry over" to requests made by your PHP script.

Making a logged-in request from your PHP script is unlikely to be possible; it would require the user to provide your web site with their Steam username, password, and one-time login token. (Which is, of course, a terrible idea from a security perspective. Don't do this.)

Unless Steam has some other API to access this data, the solution you're describing (manual copy/paste) is probably your only option.

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问