当前位置: 首页>>代码示例>>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;未经允许,请勿转载。