当前位置: 首页>>代码示例>>PHP>>正文


PHP BaseType::hasAttachment方法代码示例

本文整理汇总了PHP中DTS\eBaySDK\Types\BaseType::hasAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseType::hasAttachment方法的具体用法?PHP BaseType::hasAttachment怎么用?PHP BaseType::hasAttachment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DTS\eBaySDK\Types\BaseType的用法示例。


在下文中一共展示了BaseType::hasAttachment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: callOperation

 /**
  * Sends an API request.
  *
  * This method overrides the parent so that it can modify
  * the request object before is handled by the parent class.
  *
  * @param string $name The name of the operation.
  * @param \DTS\eBaySDK\Types\BaseType $request Request object containing the request information.
  * @param string The name of the PHP class that will be created from the XML response.
  *
  * @return mixed A response object created from the XML respose.
  */
 protected function callOperation($name, \DTS\eBaySDK\Types\BaseType $request, $responseClass)
 {
     /**
        Modify the request object to add xop:Include element.
     */
     if ($name === 'uploadFile' && $request->hasAttachment()) {
         /**
            Don't modify a request if the file attachment already exists.
         */
         if (!isset($request->fileAttachment)) {
             $request->fileAttachment = new \DTS\eBaySDK\FileTransfer\Types\FileAttachment();
         }
         if (!isset($request->fileAttachment->Data)) {
             $request->fileAttachment->Data = new \DTS\eBaySDK\FileTransfer\Types\Data(['xopInclude' => new \DTS\eBaySDK\FileTransfer\Types\XopInclude(['href' => 'cid:attachment.bin@devbay.net'])]);
         }
         if (!isset($request->fileAttachment->Size)) {
             $attachment = $request->attachment();
             $request->fileAttachment->Size = strlen($attachment['data']);
         }
     }
     return parent::callOperation($name, $request, $responseClass);
 }
开发者ID:robinkanters,项目名称:ebay-sdk-php,代码行数:34,代码来源:FileTransferBaseService.php

示例2: callOperation

 /**
  * Sends an API request.
  *
  * This method overrides the parent so that it can modify
  * the request object before is handled by the parent class.
  *
  * @param string $name The name of the operation.
  * @param \DTS\eBaySDK\Types\BaseType $request Request object containing the request information.
  * @param string The name of the PHP class that will be created from the XML response.
  *
  * @return mixed A response object created from the XML respose.
  */
 protected function callOperation($name, \DTS\eBaySDK\Types\BaseType $request, $responseClass)
 {
     /**
        Modify the request object to add xop:Include element.
     */
     if ($name === 'uploadFile' && $request->hasAttachment()) {
         /**
            Don't modify a request if the file attachment already exists.
         */
         if (!isset($request->fileAttachment)) {
             $request->fileAttachment = new \DTS\eBaySDK\FileTransfer\Types\FileAttachment();
         }
         if (!isset($request->fileAttachment->Data)) {
             $request->fileAttachment->Data = '<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:attachment.bin@devbay.net"/>';
         }
         if (!isset($request->fileAttachment->Size)) {
             $attachment = $request->attachment();
             $request->fileAttachment->Size = strlen($attachment['data']);
         }
     }
     return parent::callOperation($name, $request, $responseClass);
 }
开发者ID:ronlobo,项目名称:ebay-sdk-php,代码行数:34,代码来源:FileTransferBaseService.php

示例3: buildRequestBody

 /**
  * Builds the request body string.
  *
  * @param \DTS\eBaySDK\Types\BaseType $request Request object containing the request information.
  *
  * @return string The request body.
  */
 private function buildRequestBody(\DTS\eBaySDK\Types\BaseType $request)
 {
     if (!$request->hasAttachment()) {
         return $request->toRequestXml();
     } else {
         return $this->buildXopDocument($request) . $this->buildAttachmentBody($request->attachment());
     }
 }
开发者ID:jasonthebomb,项目名称:eBayService,代码行数:15,代码来源:BaseService.php

示例4: buildRequestHeaders

 /**
  * Helper function that builds the HTTP request headers.
  *
  * @param string $name The name of the operation.
  * @param \DTS\eBaySDK\Types\BaseType $request Request object containing the request information.
  * @param string $body The request body.
  *
  * @return array An associative array of HTTP headers.
  */
 private function buildRequestHeaders($name, $request, $body)
 {
     $headers = $this->getEbayHeaders($name);
     if ($request->hasAttachment()) {
         $headers['Content-Type'] = 'multipart/related;boundary=MIME_boundary;type="application/xop+xml";start="<request.xml@devbay.net>";start-info="text/xml"';
     } else {
         $headers['Content-Type'] = 'text/xml';
     }
     $headers['Content-Length'] = strlen($body);
     return $headers;
 }
开发者ID:robinkanters,项目名称:ebay-sdk-php,代码行数:20,代码来源:BaseService.php


注:本文中的DTS\eBaySDK\Types\BaseType::hasAttachment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。