當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FacebookRequest::containsFileUploads方法代碼示例

本文整理匯總了PHP中Facebook\FacebookRequest::containsFileUploads方法的典型用法代碼示例。如果您正苦於以下問題:PHP FacebookRequest::containsFileUploads方法的具體用法?PHP FacebookRequest::containsFileUploads怎麽用?PHP FacebookRequest::containsFileUploads使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Facebook\FacebookRequest的用法示例。


在下文中一共展示了FacebookRequest::containsFileUploads方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testAVideoCanBeAddedToParams

 public function testAVideoCanBeAddedToParams()
 {
     $myFile = new FacebookVideo(__DIR__ . '/foo.txt');
     $params = ['name' => 'Foo Bar', 'source' => $myFile];
     $app = new FacebookApp('123', 'foo_secret');
     $request = new FacebookRequest($app, 'foo_token', 'POST', '/foo/videos', $params);
     $actualParams = $request->getParams();
     $this->assertTrue($request->containsFileUploads());
     $this->assertTrue($request->containsVideoUploads());
     $this->assertTrue(!isset($actualParams['source']));
     $this->assertEquals('Foo Bar', $actualParams['name']);
 }
開發者ID:barabash97,項目名稱:coolpost,代碼行數:12,代碼來源:FacebookRequestTest.php

示例2: extractFileAttachments

 /**
  * Extracts the files from a request.
  *
  * @param FacebookRequest $request
  *
  * @return string|null
  *
  * @throws FacebookSDKException
  */
 public function extractFileAttachments(FacebookRequest $request)
 {
     if (!$request->containsFileUploads()) {
         return null;
     }
     $files = $request->getFiles();
     $fileNames = [];
     foreach ($files as $file) {
         $fileName = uniqid();
         $this->addFile($fileName, $file);
         $fileNames[] = $fileName;
     }
     $request->resetFiles();
     // @TODO Does Graph support multiple uploads on one endpoint?
     return implode(',', $fileNames);
 }
開發者ID:vihoangson,項目名稱:Family,代碼行數:25,代碼來源:FacebookBatchRequest.php

示例3: prepareRequestMessage

 /**
  * Prepares the request for sending to the client handler.
  *
  * @param FacebookRequest $request
  *
  * @return array
  */
 public function prepareRequestMessage(FacebookRequest $request)
 {
     $postToVideoUrl = $request->containsVideoUploads();
     $url = $this->getBaseGraphUrl($postToVideoUrl) . $request->getUrl();
     // If we're sending files they should be sent as multipart/form-data
     if ($request->containsFileUploads()) {
         $requestBody = $request->getMultipartBody();
         $request->setHeaders(['Content-Type' => 'multipart/form-data; boundary=' . $requestBody->getBoundary()]);
     } else {
         $requestBody = $request->getUrlEncodedBody();
         $request->setHeaders(['Content-Type' => 'application/x-www-form-urlencoded']);
     }
     return [$url, $request->getMethod(), $request->getHeaders(), $requestBody->getBody()];
 }
開發者ID:stevenyeahhh,項目名稱:distrapp,代碼行數:21,代碼來源:FacebookClient.php


注:本文中的Facebook\FacebookRequest::containsFileUploads方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。