facebook-php-graph-sdk-examples
facebook-php-graph-sdk-examples copied to clipboard
Function mcrypt_create_iv() is deprecated
Deprecated: Function mcrypt_create_iv() is deprecated in /app/resources/library/facebook-sdk-v5/PseudoRandomString/McryptPseudoRandomStringGenerator.php on line 57
I got this error when use facebook php sdk v5 at PHP 7. any idea how to solve this issue ?
I also get this but only on latest PHP; 7+.
Unknown: Function mcrypt_create_iv() is deprecated in Facebook/PseudoRandomString/McryptPseudoRandomStringGenerator.php on line 57
I also got same error on PHP 7.1 can anyone solve this yet?
Solution is simple. If you are using PHP 7 or higher 'mcrypt_create_iv' is no longer supported in PHP 7. How to fix it? Look at below example.
My old code:
if (function_exists('mcrypt_create_iv')) $randomData = mcrypt_create_iv(20, MCRYPT_DEV_URANDOM);
and I need to make some changes like this:
if (function_exists('random_bytes')) $randomData = random_bytes(20);