【问题标题】:unable to load the GetMyMessagesRequestType class when calling the namespace调用命名空间时无法加载 GetMyMessagesRequestType 类
【发布时间】:2017-10-26 08:53:40
【问题描述】:

我无法从位于以下命名空间中的 ebay-sdk 加载 GetMyMessagesRequestType 类:

 use DTS\eBaySDK\Trading\Services;
 use DTS\ebaySDK\Trading\Types;

当我调用以下命令时:

    use DTS\eBaySDK\Shopping\Services;
    use DTS\ebaySDK\Shopping\Types;

ebayTime 完美加载的相关类:

 $service = new Services\ShoppingService();

  // Create the request object.
  $request = new Types\GeteBayTimeRequestType();

  // Send the request to the service operation.
  $response = $service->geteBayTime($request);

  // Output the result of calling the service operation.
  printf("The official eBay time is: %s\n", $response->Timestamp->format('H:i (\G\M\T) \o\n l jS Y'));

此代码有效。

但我现在更改的代码如下所示:

   $service = new Services\TradingService([
    'authToken'=> "",
    'credentials' => [
      'appId' => '',
      'certId' => '',
      'devId' => ''
    ],
    'siteId'=>0
  ]);



  $request = new Types\GetMyMessagesRequestType();

我收到以下错误消息:

 Attempted to load class "GetMyMessagesRequestType" from namespace "DTS\ebaySDK\Trading\Types".
  Did you forget a "use" statement for "DTS\eBaySDK\Trading\Types\GetMyMessagesRequestType"

有什么想法是我无法解决以完成项目的一件小事吗?

【问题讨论】:

    标签: php symfony php-7 ebay-api


    【解决方案1】:

    当您将 use 语句更改为 DTS\ebaySDK\Shopping\Types 时,您尝试实例化的类在错误的命名空间中查找:DTS\ebaySDK\Shopping\Types\GetMyMessagesRequestType 不存在。

    1. 要么将违规行更改为:

      $request = new Types\GetMyMessagesRequestType();
      

      进入(注意前导反斜杠):

      $request = new \DTS\eBaySDK\Trading\Types\GetMyMessagesRequestType();
      
    2. 或者在正确的命名空间中添加use语句:

      use DTS\eBaySDK\Trading\Types\GetMyMessagesRequestType;
      
      $request = new GetMyMessagesRequestType();
      

    【讨论】:

      猜你喜欢
      • 2023-04-10
      • 2011-06-22
      • 2017-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-10
      • 2013-03-12
      相关资源
      最近更新 更多