當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。