简体   繁体   English

Facebook登录:该应用程序的域中未包含URL! 我收到错误> FacebookClient.php中的可捕获致命错误

[英]Facebook Login: URL isn't included in the app's domains! I get error > Catchable fatal error in FacebookClient.php

I know many such questions have already been asked tried a lot then after posting the question. 我知道很多这样的问题在发布问题后已经被问了很多。 I`ll start from beginning: Few days ago I tried to sing in with my facebook user I get message from facebook: „URL isn't included in the app's domains!“ I solved it by adding URL in https://developers.facebook.com/apps/.../fb-login/settings/ Valid OAuth redirect URIs. 我将从头开始:几天前,我尝试与我的Facebook用户一起唱歌,我收到来自Facebook的消息:“ URL不包含在应用程序的域中!”我通过在https:// developers中添加URL来解决了这个问题。 facebook.com/apps/.../fb-login/settings/有效的OAuth重定向URI。

The problems that I have now is when user tries to login with facebook account see this error 我现在遇到的问题是当用户尝试使用Facebook帐户登录时看到此错误
Catchable fatal error: Argument 4 passed to Facebook\\FacebookResponse::__construct() must be of the type array, null given, called in /home/sportobatai/public_html/TOTASPORT/facebook-php-sdk/FacebookClient.php on line 225 and defined in /home/sportobatai/public_html/TOTASPORT/facebook-php-sdk/FacebookResponse.php on line 75

1. The link "Login with facebook" 1.链接“使用facebook登录”
https://www.facebook.com/v2.2/dialog/oauth?client_id=XXXXXXXXXXXXX&state=829ee1c76aa23a76223dd500d49289b6&response_type=code&sdk=php-sdk-5.0.0&redirect_uri=http%3A%2F%2Ftotasport.com%2F&scope=email https://www.facebook.com/v2.2/dialog/oauth?client_id=XXXXXXXXXXXXX&state=829ee1c76aa23a76223dd500d49289b6&response_type=code&sdk=php-sdk-5.0.0&redirect_uri=http%3A%2F%2Ftotasport.com%2F&scope=email

2. The link when user sings with facebook account: 2.当用户使用Facebook帐户唱歌时的链接:
http://totasport.com/?code=AQBVHr63oHzB2nYdDQMet0NrpW7QJ_LEdzRfApdGnyywLgzwT-nv8a3pfFmKPSGHYkjzsjt9D0y74nr-GWyLMSbPPC_E8PKYYXG7G1-U8cn-KDPd3dd3Rw-Ysot8s8tq7MlQ6OIVk-YFbN7hc5SM_-K9EbBb0ofpl5ypfRbIUvI3c-XxVoMKxIWRYf1PR9l5CPWNLWjbmx2ceADdS5cxvrx2gEK-5CR1ZB77y-YRCEB4yNhzcsWJKPc5xWvh2e4ss8S_8CHvfvMF7JPK7mB8YrFdB0LK69adOMYjUF76fGqpnj2EybizYvo4GpsjkqANrC4&state=829ee1c76aa23a76223dd500d49289b6# = http://totasport.com/?code=AQBVHr63oHzB2nYdDQMet0NrpW7QJ_LEdzRfApdGnyywLgzwT-nv8a3pfFmKPSGHYkjzsjt9D0y74nr-GWyLMSbPPC_E8PKYYXG7G1-U8cn-KDPd3dd3Rw-Ysot8s8tq7MlQ6OIVk-YFbN7hc5SM_-K9EbBb0ofpl5ypfRbIUvI3c-XxVoMKxIWRYf1PR9l5CPWNLWjbmx2ceADdS5cxvrx2gEK-5CR1ZB77y-YRCEB4yNhzcsWJKPc5xWvh2e4ss8S_8CHvfvMF7JPK7mB8YrFdB0LK69adOMYjUF76fGqpnj2EybizYvo4GpsjkqANrC4&state=829ee1c76aa23a76223dd500d49289b6# =

The error appears. 出现错误。

3. The Code what I used to make a login with Facebook: 3.该代码我用来登录Facebook的代码:
https://www.codexworld.com/login-with-facebook-using-php/ https://www.codexworld.com/login-with-facebook-using-php/

4. Screens from developers.facebook.com: 4.来自developers.facebook.com的屏幕:
> facebook app settings image > Facebook应用程序设置图像
> facebook login settings image > Facebook登录设置图片

5. FacebookClient.php 5. FacebookClient.php

 <?php /** * Copyright 2014 Facebook, Inc. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to * use, copy, modify, and distribute this software in source code or binary * form for use in connection with the web services and APIs provided by * Facebook. * * As with any software that integrates with the Facebook platform, your use * of this software is subject to the Facebook Developer Principles and * Policies [http://developers.facebook.com/policy/]. This copyright notice * shall be included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ namespace Facebook; use Facebook\\HttpClients\\FacebookHttpClientInterface; use Facebook\\HttpClients\\FacebookCurlHttpClient; use Facebook\\HttpClients\\FacebookStreamHttpClient; use Facebook\\Exceptions\\FacebookSDKException; /** * Class FacebookClient * * @package Facebook */ class FacebookClient { /** * @const string Production Graph API URL. */ const BASE_GRAPH_URL = 'https://graph.facebook.com'; /** * @const string Graph API URL for video uploads. */ const BASE_GRAPH_VIDEO_URL = 'https://graph-video.facebook.com'; /** * @const string Beta Graph API URL. */ const BASE_GRAPH_URL_BETA = 'https://graph.beta.facebook.com'; /** * @const string Beta Graph API URL for video uploads. */ const BASE_GRAPH_VIDEO_URL_BETA = 'https://graph-video.beta.facebook.com'; /** * @const int The timeout in seconds for a normal request. */ const DEFAULT_REQUEST_TIMEOUT = 60; /** * @const int The timeout in seconds for a request that contains file uploads. */ const DEFAULT_FILE_UPLOAD_REQUEST_TIMEOUT = 3600; /** * @const int The timeout in seconds for a request that contains video uploads. */ const DEFAULT_VIDEO_UPLOAD_REQUEST_TIMEOUT = 7200; /** * @var bool Toggle to use Graph beta url. */ protected $enableBetaMode = false; /** * @var FacebookHttpClientInterface HTTP client handler. */ protected $httpClientHandler; /** * @var int The number of calls that have been made to Graph. */ public static $requestCount = 0; /** * Instantiates a new FacebookClient object. * * @param FacebookHttpClientInterface|null $httpClientHandler * @param boolean $enableBeta */ public function __construct(FacebookHttpClientInterface $httpClientHandler = null, $enableBeta = false) { $this->httpClientHandler = $httpClientHandler ?: $this->detectHttpClientHandler(); $this->enableBetaMode = $enableBeta; } /** * Sets the HTTP client handler. * * @param FacebookHttpClientInterface $httpClientHandler */ public function setHttpClientHandler(FacebookHttpClientInterface $httpClientHandler) { $this->httpClientHandler = $httpClientHandler; } /** * Returns the HTTP client handler. * * @return FacebookHttpClientInterface */ public function getHttpClientHandler() { return $this->httpClientHandler; } /** * Detects which HTTP client handler to use. * * @return FacebookHttpClientInterface */ public function detectHttpClientHandler() { return function_exists('curl_init') ? new FacebookCurlHttpClient() : new FacebookStreamHttpClient(); } /** * Toggle beta mode. * * @param boolean $betaMode */ public function enableBetaMode($betaMode = true) { $this->enableBetaMode = $betaMode; } /** * Returns the base Graph URL. * * @param boolean $postToVideoUrl Post to the video API if videos are being uploaded. * * @return string */ public function getBaseGraphUrl($postToVideoUrl = false) { if ($postToVideoUrl) { return $this->enableBetaMode ? static::BASE_GRAPH_VIDEO_URL_BETA : static::BASE_GRAPH_VIDEO_URL; } return $this->enableBetaMode ? static::BASE_GRAPH_URL_BETA : static::BASE_GRAPH_URL; } /** * 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(), ]; } /** * Makes the request to Graph and returns the result. * * @param FacebookRequest $request * * @return FacebookResponse * * @throws FacebookSDKException */ public function sendRequest(FacebookRequest $request) { if (get_class($request) === 'FacebookRequest') { $request->validateAccessToken(); } list($url, $method, $headers, $body) = $this->prepareRequestMessage($request); // Since file uploads can take a while, we need to give more time for uploads $timeOut = static::DEFAULT_REQUEST_TIMEOUT; if ($request->containsFileUploads()) { $timeOut = static::DEFAULT_FILE_UPLOAD_REQUEST_TIMEOUT; } elseif ($request->containsVideoUploads()) { $timeOut = static::DEFAULT_VIDEO_UPLOAD_REQUEST_TIMEOUT; } // Should throw `FacebookSDKException` exception on HTTP client error. // Don't catch to allow it to bubble up. $rawResponse = $this->httpClientHandler->send($url, $method, $body, $headers, $timeOut); static::$requestCount++; $returnResponse = new FacebookResponse( $request, $rawResponse->getBody(), $rawResponse->getHttpResponseCode(), $rawResponse->getHeaders() ); if ($returnResponse->isError()) { throw $returnResponse->getThrownException(); } return $returnResponse; } /** * Makes a batched request to Graph and returns the result. * * @param FacebookBatchRequest $request * * @return FacebookBatchResponse * * @throws FacebookSDKException */ public function sendBatchRequest(FacebookBatchRequest $request) { $request->prepareRequestsForBatch(); $facebookResponse = $this->sendRequest($request); return new FacebookBatchResponse($request, $facebookResponse); } } 
6. FacebookResponse.php 6. FacebookResponse.php

 <?php /** * Copyright 2014 Facebook, Inc. * * You are hereby granted a non-exclusive, worldwide, royalty-free license to * use, copy, modify, and distribute this software in source code or binary * form for use in connection with the web services and APIs provided by * Facebook. * * As with any software that integrates with the Facebook platform, your use * of this software is subject to the Facebook Developer Principles and * Policies [http://developers.facebook.com/policy/]. This copyright notice * shall be included in all copies or substantial portions of the software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ namespace Facebook; use Facebook\\GraphNodes\\GraphNodeFactory; use Facebook\\Exceptions\\FacebookResponseException; use Facebook\\Exceptions\\FacebookSDKException; /** * Class FacebookResponse * * @package Facebook */ class FacebookResponse { /** * @var int The HTTP status code response from Graph. */ protected $httpStatusCode; /** * @var array The headers returned from Graph. */ protected $headers; /** * @var string The raw body of the response from Graph. */ protected $body; /** * @var array The decoded body of the Graph response. */ protected $decodedBody = []; /** * @var FacebookRequest The original request that returned this response. */ protected $request; /** * @var FacebookSDKException The exception thrown by this request. */ protected $thrownException; /** * Creates a new Response entity. * * @param FacebookRequest $request * @param string|null $body * @param int|null $httpStatusCode * @param array|null $headers */ public function __construct(FacebookRequest $request, $body = null, $httpStatusCode = null, array $headers = []) { $this->request = $request; $this->body = $body; $this->httpStatusCode = $httpStatusCode; $this->headers = $headers; $this->decodeBody(); } /** * Return the original request that returned this response. * * @return FacebookRequest */ public function getRequest() { return $this->request; } /** * Return the FacebookApp entity used for this response. * * @return FacebookApp */ public function getApp() { return $this->request->getApp(); } /** * Return the access token that was used for this response. * * @return string|null */ public function getAccessToken() { return $this->request->getAccessToken(); } /** * Return the HTTP status code for this response. * * @return int */ public function getHttpStatusCode() { return $this->httpStatusCode; } /** * Return the HTTP headers for this response. * * @return array */ public function getHeaders() { return $this->headers; } /** * Return the raw body response. * * @return string */ public function getBody() { return $this->body; } /** * Return the decoded body response. * * @return array */ public function getDecodedBody() { return $this->decodedBody; } /** * Get the app secret proof that was used for this response. * * @return string|null */ public function getAppSecretProof() { return $this->request->getAppSecretProof(); } /** * Get the ETag associated with the response. * * @return string|null */ public function getETag() { return isset($this->headers['ETag']) ? $this->headers['ETag'] : null; } /** * Get the version of Graph that returned this response. * * @return string|null */ public function getGraphVersion() { return isset($this->headers['Facebook-API-Version']) ? $this->headers['Facebook-API-Version'] : null; } /** * Returns true if Graph returned an error message. * * @return boolean */ public function isError() { return isset($this->decodedBody['error']); } /** * Throws the exception. * * @throws FacebookSDKException */ public function throwException() { throw $this->thrownException; } /** * Instantiates an exception to be thrown later. */ public function makeException() { $this->thrownException = FacebookResponseException::create($this); } /** * Returns the exception that was thrown for this request. * * @return FacebookSDKException|null */ public function getThrownException() { return $this->thrownException; } /** * Convert the raw response into an array if possible. * * Graph will return 2 types of responses: * - JSON(P) * Most responses from Grpah are JSON(P) * - application/x-www-form-urlencoded key/value pairs * Happens on the `/oauth/access_token` endpoint when exchanging * a short-lived access token for a long-lived access token * - And sometimes nothing :/ but that'd be a bug. */ public function decodeBody() { $this->decodedBody = json_decode($this->body, true); if ($this->decodedBody === null) { $this->decodedBody = []; parse_str($this->body, $this->decodedBody); } elseif (is_bool($this->decodedBody)) { // Backwards compatibility for Graph < 2.1. // Mimics 2.1 responses. // @TODO Remove this after Graph 2.0 is no longer supported $this->decodedBody = ['success' => $this->decodedBody]; } elseif (is_numeric($this->decodedBody)) { $this->decodedBody = ['id' => $this->decodedBody]; } if (!is_array($this->decodedBody)) { $this->decodedBody = []; } if ($this->isError()) { $this->makeException(); } } /** * Instantiate a new GraphObject from response. * * @param string|null $subclassName The GraphNode sub class to cast to. * * @return \\Facebook\\GraphNodes\\GraphObject * * @throws FacebookSDKException * * @deprecated 5.0.0 getGraphObject() has been renamed to getGraphNode() * @todo v6: Remove this method */ public function getGraphObject($subclassName = null) { return $this->getGraphNode($subclassName); } /** * Instantiate a new GraphNode from response. * * @param string|null $subclassName The GraphNode sub class to cast to. * * @return \\Facebook\\GraphNodes\\GraphNode * * @throws FacebookSDKException */ public function getGraphNode($subclassName = null) { $factory = new GraphNodeFactory($this); return $factory->makeGraphNode($subclassName); } /** * Convenience method for creating a GraphAlbum collection. * * @return \\Facebook\\GraphNodes\\GraphAlbum * * @throws FacebookSDKException */ public function getGraphAlbum() { $factory = new GraphNodeFactory($this); return $factory->makeGraphAlbum(); } /** * Convenience method for creating a GraphPage collection. * * @return \\Facebook\\GraphNodes\\GraphPage * * @throws FacebookSDKException */ public function getGraphPage() { $factory = new GraphNodeFactory($this); return $factory->makeGraphPage(); } /** * Convenience method for creating a GraphSessionInfo collection. * * @return \\Facebook\\GraphNodes\\GraphSessionInfo * * @throws FacebookSDKException */ public function getGraphSessionInfo() { $factory = new GraphNodeFactory($this); return $factory->makeGraphSessionInfo(); } /** * Convenience method for creating a GraphUser collection. * * @return \\Facebook\\GraphNodes\\GraphUser * * @throws FacebookSDKException */ public function getGraphUser() { $factory = new GraphNodeFactory($this); return $factory->makeGraphUser(); } /** * Convenience method for creating a GraphEvent collection. * * @return \\Facebook\\GraphNodes\\GraphEvent * * @throws FacebookSDKException */ public function getGraphEvent() { $factory = new GraphNodeFactory($this); return $factory->makeGraphEvent(); } /** * Convenience method for creating a GraphGroup collection. * * @return \\Facebook\\GraphNodes\\GraphGroup * * @throws FacebookSDKException */ public function getGraphGroup() { $factory = new GraphNodeFactory($this); return $factory->makeGraphGroup(); } /** * Instantiate a new GraphList from response. * * @param string|null $subclassName The GraphNode sub class to cast list items to. * @param boolean $auto_prefix Toggle to auto-prefix the subclass name. * * @return \\Facebook\\GraphNodes\\GraphList * * @throws FacebookSDKException * * @deprecated 5.0.0 getGraphList() has been renamed to getGraphEdge() * @todo v6: Remove this method */ public function getGraphList($subclassName = null, $auto_prefix = true) { return $this->getGraphEdge($subclassName, $auto_prefix); } /** * Instantiate a new GraphEdge from response. * * @param string|null $subclassName The GraphNode sub class to cast list items to. * @param boolean $auto_prefix Toggle to auto-prefix the subclass name. * * @return \\Facebook\\GraphNodes\\GraphEdge * * @throws FacebookSDKException */ public function getGraphEdge($subclassName = null, $auto_prefix = true) { $factory = new GraphNodeFactory($this); return $factory->makeGraphEdge($subclassName, $auto_prefix); } } 

Please give me some tips how to solve that problem. 请给我一些技巧,以解决该问题。

if you using sdk facebook php, please make into method "getAccessToken()" the "redirect uri" valid, example: 如果您使用sdk facebook php,请将“ redirect uri”设为有效的“ getAccessToken()”方法,例如:

<?php
...
$helper->getAccessToken('https://your-site.com/re-OAuth.php');
...
?>

where re-OAuth.php is is a return script.- (for example) re-OAuth.php是返回脚本。-(例如)

This will solve the problem .. greetings.- 这将解决问题..问候。-

Sorry for my bad english 对不起,我的英语不好

Thank you all who replied, your replies helped me to find a path to solve it. 谢谢所有答复的人,您的答复帮助我找到了解决之道。 I have updated all facebook/php-graph-sdk files to 5.x version from https://github.com/facebook/php-graph-sdk and that solved this error. 我已经从https://github.com/facebook/php-graph-sdk将所有facebook / php-graph-sdk文件更新到5.x版本,这解决了此错误。 So, case is closed. 因此,案例已结案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Facebook 显示错误:无法加载 URL:此 URL 的域未包含在应用程序的域中 - Facebook showing error: Can't Load URL: The domain of this URL isn't included in the app's domains facebook登录名:无法加载URL:该URL的域未包含在应用程序的域中 - facebook login : Can't Load URL: The domain of this URL isn't included in the app's domains 图表返回错误:无法加载网址:此网址的域未包含在应用的域中 - Graph returned an error: Can't Load URL: The domain of this URL isn't included in the app's domains Facebook Auth:无法加载URL:此URL的域未包含在应用的域中 - Facebook Auth: Can't Load URL: The domain of this URL isn't included in the app's domains Facebook App - 此URL的域名未包含在应用程序的域中。 为什么? - Facebook App - The domain of this URL isn't included in the app's domains. Why? Facebook身份验证,严格的OAuth模式:此URL的域不包含在应用程序的域中 - Facebook Authentication, Strict OAuth Mode: The domain of this URL isn't included in the app's domains PHP可捕获的致命错误 - PHP Catchable fatal error 可捕获的类的致命错误-PHP - Catchable fatal error of a Class - PHP PHP可捕获的致命错误-服务器上 - PHP Catchable Fatal Error - on server PHP搜索-可捕获的致命错误 - PHP search - catchable fatal error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM