本文整理汇总了PHP中Facebook\FacebookRequest::getUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP FacebookRequest::getUrl方法的具体用法?PHP FacebookRequest::getUrl怎么用?PHP FacebookRequest::getUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Facebook\FacebookRequest
的用法示例。
在下文中一共展示了FacebookRequest::getUrl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAuthenticationParamsAreStrippedAndReapplied
public function testAuthenticationParamsAreStrippedAndReapplied()
{
$app = new FacebookApp('123', 'foo_secret');
$request = new FacebookRequest($app, $accessToken = 'foo_token', $method = 'GET', $endpoint = '/foo', $params = ['access_token' => 'foo_token', 'appsecret_proof' => 'bar_app_secret', 'bar' => 'baz']);
$url = $request->getUrl();
$expectedParams = 'bar=baz&access_token=foo_token&appsecret_proof=df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9';
$expectedUrl = '/' . Facebook::DEFAULT_GRAPH_VERSION . '/foo?' . $expectedParams;
$this->assertEquals($expectedUrl, $url);
$params = $request->getParams();
$expectedParams = ['access_token' => 'foo_token', 'appsecret_proof' => 'df4256903ba4e23636cc142117aa632133d75c642bd2a68955be1443bd14deb9', 'bar' => 'baz'];
$this->assertEquals($expectedParams, $params);
}
示例2: requestEntityToBatchArray
/**
* Converts a Request entity into an array that is batch-friendly.
*
* @param FacebookRequest $request The request entity to convert.
* @param string|null $requestName The name of the request.
* @param string|null $attachedFiles Names of files associated with the request.
*
* @return array
*/
public function requestEntityToBatchArray(FacebookRequest $request, $requestName = null, $attachedFiles = null)
{
$compiledHeaders = [];
$headers = $request->getHeaders();
foreach ($headers as $name => $value) {
$compiledHeaders[] = $name . ': ' . $value;
}
$batch = ['headers' => $compiledHeaders, 'method' => $request->getMethod(), 'relative_url' => $request->getUrl()];
// Since file uploads are moved to the root request of a batch request,
// the child requests will always be URL-encoded.
$body = $request->getUrlEncodedBody()->getBody();
if ($body) {
$batch['body'] = $body;
}
if (isset($requestName)) {
$batch['name'] = $requestName;
}
if (isset($attachedFiles)) {
$batch['attached_files'] = $attachedFiles;
}
// @TODO Add support for "omit_response_on_success"
// @TODO Add support for "depends_on"
// @TODO Add support for JSONP with "callback"
return $batch;
}
示例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()];
}