我正在开发一个G2A api,该API返回一个非常奇怪的对象,并且我无法访问其中一个元素,该元素为“ [images]”,并且位于一个非常奇怪的键“ [apiResponseParsed:G2A \ IntegrationApi \ Response \ ResponseAbstract:私有]“
我已经尝试过:
$ response-> apiResponseParsed ['docs'] [0] ['images']
这是对象,print_r($ response)的响应;
G2A\IntegrationApi\Response\ProductsListResponse Object
(
[products:G2A\IntegrationApi\Response\ProductsListResponse:private] => Array
(
[0] => G2A\IntegrationApi\Model\Product Object
(
[id:G2A\IntegrationApi\Model\Product:private] => 10000032198001
[name:G2A\IntegrationApi\Model\Product:private] => Minecraft: Windows 10 Edition Microsoft Key GLOBAL
[type:G2A\IntegrationApi\Model\Product:private] => egoods
[slug:G2A\IntegrationApi\Model\Product:private] => /minecraft-windows-10-edition-microsoft-key-global-i10000032198001
[qty:G2A\IntegrationApi\Model\Product:private] => 1602
[minPrice:G2A\IntegrationApi\Model\Product:private] => 2.49
[thumbnail:G2A\IntegrationApi\Model\Product:private] => https://images.g2a.com/images/58x58/0x1x1/96f82926837f/5d1ca6a47e696c05dd4f1e92
[smallImage:G2A\IntegrationApi\Model\Product:private] => https://images.g2a.com/images/230x336/0x1x1/ab9d2d4f7e86/5d1ca6a47e696c05dd4f1e92
[description:G2A\IntegrationApi\Model\Product:private] =>
Freedom of creation
Build whatever you like with a variety of different blocks. Create advanced homes and objects, develop complex cities, villages, mines and even entire environments. Cut down trees, mine stone, collect grass and fight with dangerous monsters. An advanced crafting mechanism and endless resources allow you to create almost everything you can imagine.
Feel the satisfaction of building your own town, animal pens, farmlands, and even an automated mushroom farm!
Breathtaking landscapes
Imagine an endless world full of cubic mountains, valleys, and canyons. All the visuals look nice and natural and the pixel textures provide a unique charm. Explore endless deserts, rainforests, underground tunnels and mines, hidden temples and even another dimension.
Get surprised by the abundance of animals, plants, and building materials. Immerse yourself into the unpredictable, wild and beautiful world of Minecraft.
Infinity & randomness
Each time when a new game starts, a completely fresh world is being generated. The whole new geographic regions emerge. Green valleys, swamps, mountains, and deserts. Everything in Minecraft is infinite, so you can enjoy tons of hours of sightseeing!
Survive the darkness
Start a new game and you will appear in a random place of a randomly generated world. As a lonely player without any equipment, you are completely on your own, doomed to survive. Hurry up because you have only one day to build a shelter, find food, and to avoid meeting monsters at night. If you fail to build a bed before night, you will be forced to wait and listen to the sounds of monsters. Beware of creepers, they are very sneaky and can destroy everything you build. The first night always is an extremely exciting experience!Build a safe shelter and try to survive as long as possible. Collect fruit, plant vegetables, and bake meat. Stay away from the darkness because when the night comes, monsters awake.
Set a trap, forge armor & sword and defend yourself against dangerous enemies.
Mine raw materials
Create well-developed mines to extract coal, iron, gold, silver and other important raw materials. Visit randomly generated caves in search of rare diamonds, destroy the monster's habitats in abandoned dungeons and be careful not to fall into the lava.
Texture packs & Maps & Skins
Minecraft is a very popular game which is enjoyed by millions of players around the world. Enjoy the Minecraft in its various faces. Try different skins, texture packs and download custom world maps created by other, extremely talented players. Discover endless amount of various mods which can completely change your game.
Enjoyable multiplayer mode
Crafting with your friends can bring hours of entertainment! Raise majestic constructions and build infinite towns & villages with players from all over the world. Go public and show your excellent building skills online.
Discover polished Minecraft!
Minecraft: Windows 10 Edition is a lot more optimized, smoother, and positive looking.
Enjoy completely different options menu, 56 total achievements more than PC Minecraft.
Buy custom skins and texture packs from Minecraft Store, connect with your friends through Xbox Live. Easily change your game mode at any time. Download and export world files with the ending .mcworld to share with other people. Invite friends to play on your own personal world or create a server to play online with them. Minecraft: Windows 10 Edition is compatible with various virtual reality headsets and with the Microsoft team working on it to make the game smoother and more optimized, you can enjoy tons of new implementations!
[region:G2A\IntegrationApi\Model\Product:private] => GLOBAL
[developer:G2A\IntegrationApi\Model\Product:private] =>
[publisher:G2A\IntegrationApi\Model\Product:private] =>
[platform:G2A\IntegrationApi\Model\Product:private] => Other
[restrictions:G2A\IntegrationApi\Model\Product:private] => Array
(
[pegi_violence] =>
[pegi_profanity] =>
[pegi_discrimination] =>
[pegi_drugs] =>
[pegi_fear] =>
[pegi_gambling] =>
[pegi_online] =>
[pegi_sex] =>
)
[requirements:G2A\IntegrationApi\Model\Product:private] => Array
(
[minimal] => Array
(
[reqprocessor] => Intel Core i3-3210 3.2 GHz / AMD A8-7600 APU 3.1 GHz or equivalent
[reqgraphics] => Intel HD Graphics 4000 (Ivy Bridge) or AMD Radeon R5 series (Kaveri line) with OpenGL 4.4 / Nvidia GeForce 400 Series or AMD Radeon HD 7000 series with OpenGL 4.4.
[reqmemory] => 4 GB
[reqdiskspace] => 226 MB
[reqsystem] => Windows 10
[reqother] =>
)
[recommended] => Array
(
[reqprocessor] =>
[reqgraphics] =>
[reqmemory] =>
[reqdiskspace] =>
[reqsystem] =>
[reqother] =>
)
)
[videos:G2A\IntegrationApi\Model\Product:private] => Array
(
[0] => Array
(
[type] => YOUTUBE
[url] => https://www.youtube.com/embed/MmB9b5njVbA
)
)
[categories:G2A\IntegrationApi\Model\Product:private] => Array
(
[0] => Array
(
[id] => 2
[name] => All products
)
[1] => Array
(
[id] => 2
[name] => Default Category
)
[2] => Array
(
[id] => 11
[name] => All
)
[3] => Array
(
[id] => 543
[name] => Sort List
)
[4] => Array
(
[id] => 544
[name] => Adventure
)
[5] => Array
(
[id] => 791
[name] => Microsoft
)
[6] => Array
(
[id] => 2126
[name] => Ofertas Latinoamérica
)
[7] => Array
(
[id] => 2174
[name] => SPRING SALE
)
[8] => Array
(
[id] => 2193
[name] => Games under 10 EUR
)
[9] => Array
(
[id] => 2228
[name] => Sandbox
)
[10] => Array
(
[id] => 2232
[name] => Couch Co-op
)
[11] => Array
(
[id] => 2235
[name] => Juegos Baratos
)
)
)
)
[apiResponse:G2A\IntegrationApi\Response\ResponseAbstract:private] => GuzzleHttp\Psr7\Response Object
(
[reasonPhrase:GuzzleHttp\Psr7\Response:private] => OK
[statusCode:GuzzleHttp\Psr7\Response:private] => 200
[headers:GuzzleHttp\Psr7\Response:private] => Array
(
[Server] => Array
(
[0] => nginx
)
[Content-Type] => Array
(
[0] => application/json; charset=UTF-8
)
[Access-Control-Allow-Origin] => Array
(
[0] => *
)
[Cache-Control] => Array
(
[0] => no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0
)
[Expires] => Array
(
[0] => 0
)
[Last-Modified] => Array
(
[0] => 2019-07-05 13:34:04.600280153 +0100 BST
)
[Pragma] => Array
(
[0] => no-cache
)
[Strict-Transport-Security] => Array
(
[0] => max-age=31536000;
[1] => max-age=31536000;
)
[Vary] => Array
(
[0] => Origin
)
[X-Content-Type-Options] => Array
(
[0] => nosniff
[1] => nosniff
)
[X-Frame-Options] => Array
(
[0] => SAMEORIGIN
[1] => SAMEORIGIN
)
[g2a-server] => Array
(
[0] => minion02
)
[Content-Length] => Array
(
[0] => 7421
)
[Date] => Array
(
[0] => Fri, 05 Jul 2019 12:34:05 GMT
)
[Connection] => Array
(
[0] => keep-alive
)
)
[headerNames:GuzzleHttp\Psr7\Response:private] => Array
(
[server] => Server
[content-type] => Content-Type
[access-control-allow-origin] => Access-Control-Allow-Origin
[cache-control] => Cache-Control
[expires] => Expires
[last-modified] => Last-Modified
[pragma] => Pragma
[strict-transport-security] => Strict-Transport-Security
[vary] => Vary
[x-content-type-options] => X-Content-Type-Options
[x-frame-options] => X-Frame-Options
[g2a-server] => g2a-server
[content-length] => Content-Length
[date] => Date
[connection] => Connection
)
[protocol:GuzzleHttp\Psr7\Response:private] => 1.1
[stream:GuzzleHttp\Psr7\Response:private] => GuzzleHttp\Psr7\Stream Object
(
[stream:GuzzleHttp\Psr7\Stream:private] => Resource id #49
[size:GuzzleHttp\Psr7\Stream:private] =>
[seekable:GuzzleHttp\Psr7\Stream:private] => 1
[readable:GuzzleHttp\Psr7\Stream:private] => 1
[writable:GuzzleHttp\Psr7\Stream:private] => 1
[uri:GuzzleHttp\Psr7\Stream:private] => php://temp
[customMetadata:GuzzleHttp\Psr7\Stream:private] => Array
(
)
)
)
[apiResponseParsed:G2A\IntegrationApi\Response\ResponseAbstract:private] => Array
(
[total] => 1
[page] => 1
[docs] => Array
(
[0] => Array
(
[id] => 10000032198001
[name] => Minecraft: Windows 10 Edition Microsoft Key GLOBAL
[type] => egoods
[slug] => /minecraft-windows-10-edition-microsoft-key-global-i10000032198001
[qty] => 1602
[minPrice] => 2.49
[retail_min_price] => 2.39
[thumbnail] => https://images.g2a.com/images/58x58/0x1x1/96f82926837f/5d1ca6a47e696c05dd4f1e92
[smallImage] => https://images.g2a.com/images/230x336/0x1x1/ab9d2d4f7e86/5d1ca6a47e696c05dd4f1e92
[coverImage] => https://images.g2a.com/images/0x0/1x1x1/911908cd0a33/5d1ca6a47e696c05dd4f1e92
[images] => Array
(
[0] => https://images.g2a.com/images/0x0/1x1x1/911908cd0a33/5d1ca6a47e696c05dd4f1e92
[1] => https://images.g2a.com/images/0x0/1x1x1/93c7e215a8ae/5beecd275bafe308021e3562
[2] => https://images.g2a.com/images/0x0/1x1x1/70f8f9707802/5912573cae653a9600349a80
[3] => https://images.g2a.com/images/0x0/1x1x1/264e4233a3f8/59125743ae653a96794da8f6
[4] => https://images.g2a.com/images/0x0/1x1x1/d2fd3199d9d7/59125742ae653a96794da8f5
[5] => https://images.g2a.com/images/0x0/1x1x1/ad9979cfb405/59125742ae653a96794da8f4
[6] => https://images.g2a.com/images/0x0/1x1x1/9a75c42d0955/591257445bafe3a4ab284d3a
[7] => https://images.g2a.com/images/0x0/1x1x1/6e9edd6414cf/591257445bafe3ac1e7c426d
[8] => https://images.g2a.com/images/0x0/1x1x1/d454915f6a1e/591257425bafe3a4ab284d38
[9] => https://images.g2a.com/images/0x0/1x1x1/bf82102fba28/5912573eae653a9600349a82
[10] => https://images.g2a.com/images/0x0/1x1x1/9a92c1c58746/591257405bafe3aad7693e72
[11] => https://images.g2a.com/images/0x0/1x1x1/77f045419dd5/59e6206d5bafe3368b351e17
[12] => https://images.g2a.com/images/0x0/1x1x1/c4b583fc9e58/597f819c5bafe31345677882
)
[description] =>
Freedom of creation
Build whatever you like with a variety of different blocks. Create advanced homes and objects, develop complex cities, villages, mines and even entire environments. Cut down trees, mine stone, collect grass and fight with dangerous monsters. An advanced crafting mechanism and endless resources allow you to create almost everything you can imagine.
Feel the satisfaction of building your own town, animal pens, farmlands, and even an automated mushroom farm!
Breathtaking landscapes
Imagine an endless world full of cubic mountains, valleys, and canyons. All the visuals look nice and natural and the pixel textures provide a unique charm. Explore endless deserts, rainforests, underground tunnels and mines, hidden temples and even another dimension.
Get surprised by the abundance of animals, plants, and building materials. Immerse yourself into the unpredictable, wild and beautiful world of Minecraft.
Infinity & randomness
Each time when a new game starts, a completely fresh world is being generated. The whole new geographic regions emerge. Green valleys, swamps, mountains, and deserts. Everything in Minecraft is infinite, so you can enjoy tons of hours of sightseeing!
Survive the darkness
Start a new game and you will appear in a random place of a randomly generated world. As a lonely player without any equipment, you are completely on your own, doomed to survive. Hurry up because you have only one day to build a shelter, find food, and to avoid meeting monsters at night. If you fail to build a bed before night, you will be forced to wait and listen to the sounds of monsters. Beware of creepers, they are very sneaky and can destroy everything you build. The first night always is an extremely exciting experience!Build a safe shelter and try to survive as long as possible. Collect fruit, plant vegetables, and bake meat. Stay away from the darkness because when the night comes, monsters awake.
Set a trap, forge armor & sword and defend yourself against dangerous enemies.
Mine raw materials
Create well-developed mines to extract coal, iron, gold, silver and other important raw materials. Visit randomly generated caves in search of rare diamonds, destroy the monster's habitats in abandoned dungeons and be careful not to fall into the lava.
Texture packs & Maps & Skins
Minecraft is a very popular game which is enjoyed by millions of players around the world. Enjoy the Minecraft in its various faces. Try different skins, texture packs and download custom world maps created by other, extremely talented players. Discover endless amount of various mods which can completely change your game.
Enjoyable multiplayer mode
Crafting with your friends can bring hours of entertainment! Raise majestic constructions and build infinite towns & villages with players from all over the world. Go public and show your excellent building skills online.
Discover polished Minecraft!
Minecraft: Windows 10 Edition is a lot more optimized, smoother, and positive looking.
Enjoy completely different options menu, 56 total achievements more than PC Minecraft.
Buy custom skins and texture packs from Minecraft Store, connect with your friends through Xbox Live. Easily change your game mode at any time. Download and export world files with the ending .mcworld to share with other people. Invite friends to play on your own personal world or create a server to play online with them. Minecraft: Windows 10 Edition is compatible with various virtual reality headsets and with the Microsoft team working on it to make the game smoother and more optimized, you can enjoy tons of new implementations!
[updated_at] => 2019-07-05 12:34:00
[release_date] =>
[region] => GLOBAL
[developer] =>
[publisher] =>
[platform] => Other
[restrictions] => Array
(
[pegi_violence] =>
[pegi_profanity] =>
[pegi_discrimination] =>
[pegi_drugs] =>
[pegi_fear] =>
[pegi_gambling] =>
[pegi_online] =>
[pegi_sex] =>
)
[requirements] => Array
(
[minimal] => Array
(
[reqprocessor] => Intel Core i3-3210 3.2 GHz / AMD A8-7600 APU 3.1 GHz or equivalent
[reqgraphics] => Intel HD Graphics 4000 (Ivy Bridge) or AMD Radeon R5 series (Kaveri line) with OpenGL 4.4 / Nvidia GeForce 400 Series or AMD Radeon HD 7000 series with OpenGL 4.4.
[reqmemory] => 4 GB
[reqdiskspace] => 226 MB
[reqsystem] => Windows 10
[reqother] =>
)
[recommended] => Array
(
[reqprocessor] =>
[reqgraphics] =>
[reqmemory] =>
[reqdiskspace] =>
[reqsystem] =>
[reqother] =>
)
)
[videos] => Array
(
[0] => Array
(
[type] => YOUTUBE
[url] => https://www.youtube.com/embed/MmB9b5njVbA
)
)
[categories] => Array
(
[0] => Array
(
[id] => 2
[name] => All products
)
[1] => Array
(
[id] => 2
[name] => Default Category
)
[2] => Array
(
[id] => 11
[name] => All
)
[3] => Array
(
[id] => 543
[name] => Sort List
)
[4] => Array
(
[id] => 544
[name] => Adventure
)
[5] => Array
(
[id] => 791
[name] => Microsoft
)
[6] => Array
(
[id] => 2126
[name] => Ofertas Latinoamérica
)
[7] => Array
(
[id] => 2174
[name] => SPRING SALE
)
[8] => Array
(
[id] => 2193
[name] => Games under 10 EUR
)
[9] => Array
(
[id] => 2228
[name] => Sandbox
)
[10] => Array
(
[id] => 2232
[name] => Couch Co-op
)
[11] => Array
(
[id] => 2235
[name] => Juegos Baratos
)
)
)
)
)
)
我希望有一个[image]数组
编辑: 这给了我一个空数组
json_decode(json_encode($yourresponse),true);
数组 ( )
答案 0 :(得分:1)
您正在使用客户端库,这将返回ProductsListResponse对象,而不是数组或json字符串。在这里看看:https://github.com/g2a-official/integration-api-client/blob/master/src/Response/ProductsListResponse.php。您可以调用$ response-> getProducts()并接收Product对象的数组,也可以仅调用$ response-> getParsed(),这将返回您要查找的数组。