反序列化 API 返回对象(PHP/Ebay API)

发布于 2024-09-04 11:59:11 字数 908 浏览 6 评论 0原文

我一直在使用 Ebay api 进行一个项目,发现它很棒。然而我现在发现了一个问题,更多与 PHP 相关。

当我从 Ebay 读取商品时,我会在数据库中存储大量详细信息。目前,只是为了它,我序列化整个返回对象并将其存储在数据库中的相关表中。

这个想法是,当我显示我的信息时,我可以在需要时提供所有详细信息。问题的出现是因为定价信息始终位于子对象中。

[ConvertedAdjustmentAmount] => __PHP_Incomplete_Class Object
    (
        [__PHP_Incomplete_Class_Name] => eBayAmountType
        [_] => 0
        [currencyID] => USD
    )

正如您所看到的,当我反序列化我的对象时,我的狡猾计划违反了不完整的类问题。我检查了以下问题,但没有成功。

强制访问 __PHP_Incomplete_Class 对象属性

主要问题在于,据我所知,价格类别存储在 Ebay api 中,那么我该如何重新创建它呢?

我一直在阅读此页面, https://www.php.net/manual /en/function.unserialize.php 并试图找出 unserialize_callback_func 我也无法弄清楚,所以任何帮助将不胜感激!

I have been working with the Ebay api for a project and have found it great. I have however found a problem now, more PHP related.

When I read my items from Ebay, I store a bunch of details in the database. Currently, just for the sake of it really, I serialize the whole return object and store it in the database in a related table.

The idea being, that when I display my information, I have all the details to hand should I need them. The problem arises in that the pricing information is always in a sub object.

[ConvertedAdjustmentAmount] => __PHP_Incomplete_Class Object
    (
        [__PHP_Incomplete_Class_Name] => eBayAmountType
        [_] => 0
        [currencyID] => USD
    )

As you can see when I unserialize my object, my cunning plan falls foul of the Incomplete class problem. I have checked the following question, without success.

forcing access to __PHP_Incomplete_Class object properties

The main issue lies, as far as I can see, in that the price class is stored in the Ebay api, so how do I recreate it?

I have been reading this page, https://www.php.net/manual/en/function.unserialize.php and trying to figure out, unserialize_callback_func which I can't figure out either, so any help would be appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心头的小情儿 2024-09-11 11:59:11

哪段代码定义了类是无关紧要的。重要的是代码在反序列化对象时加载。只要您在尝试反序列化现有对象之前加载了 eBay API(与获取对象时的方式相同),它就应该可以正常工作。

What piece of code defines the class is irrelevant. What matters is that the code be loaded at the time you deserialize the object. As long as you've loaded the eBay API (in the same way you would when fetching a new object) before you try deserializing an existing one, it should work fine.

两仪 2024-09-11 11:59:11

如果您无权访问这些库,那么您需要在序列化数据之前处理这些信息。您可以将对象转换为 stdClass 或将其洗牌为您选择的类(大概是您控制的类)。根据您拥有的信息量或信息的深度,您也可以将其存储为数组。

If you don't have access to the libraries then you'll need to deal with the information prior to serializing your data. You can convert your object to a stdClass or shuffle it off to a class of your choice (one that you control, presumably). Depending on how much information you have - or how deep the information is - you could also store it as an array.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文