Closed coharish closed 2 years ago
Same thing here Started after updated PHP from 7.4 to 8.1
Getting the same error, any solution?
It's because the access token expires and isn't refreshed automatically for some reason.
You can refresh it using the code below. Really you want to move to the v3 API (or at least the Zoho recently updated 2.0/2.1 PHP APIs)
<?php
namespace App\Helpers;
use Asciisd\Zoho\Zoho;
use zcrmsdk\oauth\ZohoOAuth;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
final class ZohoCRM {
public static function refreshToken() {
$options = Zoho::zohoOptions();
$tokenData = unserialize(file_get_contents($options['token_persistence_path'].'/zcrm_oauthtokens.txt'));
$tokenDataArray = array_values((array) $tokenData[0]);
$refreshToken = $tokenDataArray[0];
$expiry = $tokenDataArray[2];
$email = $tokenDataArray[3];
if (time()*1000 > $expiry) {
ZCRMRestClient::initialize(Zoho::zohoOptions());
$oAuthClient = ZohoOAuth::getClientInstance();
$oAuthClient->refreshAccessToken($refreshToken, $email);
}
}
} //end class
And then call
App\Helpers\ZohoCRM::refreshToken();
before you use this library in your code
@danielfaulknor the code to refresh the token didn`t worked.
How do i move to v3 Api or Zoho 2.0/2.1 PHP Api
@coharish @rogerio-pereira sorry for the late, but this issue is caused by PHP 8.0, and this bug is also not on asciisd/zoho
package. It's related to the original Zoho package, and unfortunately, v2 is not supported by Zoho now, and we need to move to v3, so I am preparing a new package using v3 API. Once it is finished, I will announce it here.
@aemaddin do you have any idea when you`ll be able to release the new package? Its been 20 days and people in my job is asking a deadline, not sure if worth doing the integration from scratch or wait for your new release
When inserting records, getting below exception
Type of zcrmsdk\oauth\exception\ZohoOAuthException::$file must be string (as in class Exception) {"exception":"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0): Type of zcrmsdk\oauth\exception\ZohoOAuthException::$file must be string (as in class Exception) at /var/www/html/backend/vendor/zohocrm/php-sdk-archive/src/oauth/exception/ZohoOAuthException.php:4)
$record = new ZohoCrm(); $record->setValue('full_name', ''); $record->create(); // This triggeres the above exception.
Note: This is working from the local environment but fails in production or staging.