Skip to main content

Posts

Showing posts from April, 2020

Solution-Guzzle idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated

Solution-Guzzle idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated Guzzle is a PHP package that use by many frameworks like CakePHP. With PHP > 7, guzzlehttp gives an error like idn_to_ascii()  is deprecated. So we can solve these issues by 1) Downgrade Guzzle 2) Reinstall Packages 3) Upgrade PHP Version If your issue still exists and then we can try to avoid deprecated errors by adding @ before idn_to_ascii() function, it will prevent to generate deprecation errors for this function. Yes we do not make changes in vendor files and also it's not a good way to handle error but sometimes it works and that's all we wanna do. Example: For me its showing error like idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated [ ROOT/vendor/guzzlehttp/guzzle/src/Utils.php , line 35 ] SO i have opened Utils.php file and added @ before function like below code BEFORE public static function idnUriConvert(UriInterface $uri, $options = 0) { if ($uri->getHost()) {

Cakephp Cross-site request forgery validation failed. Required param “state” missing Facebook Login Solution

Solution : Cakephp Facebook Login Cross-site request forgery validation failed. Required param “state” missing. When we try to integrate Facebook Login(Social Login with Facebook) with CakePHP, sometimes we get an error like "Facebook SDK error: Cross-site request forgery validation failed. Required param “state” missing from persistent data" Question: Why I am getting this error? Answer: This is the session issue because Facebook handles access token and csrf with session and most frameworks like laravel, YII, Codeigniter, CakePHP handles session differently compare to CorePHP, So we need to change session handler according to the framework. For this tutorial, I am using CakePHP 4 version but it will be the same for CakePHP 3 also. So first we will create our custom session handler. so create a new file in src\Handler\MyFbPersistentDataHandler.php NOTE: If the Handler folder does not exists by default then create it and then create a file in it. <?php