Closed smenzer closed 1 year ago
Hi @smenzer. Currently no it does not support API v2. It is planned to take care of it in a near future though.
@tristanjahier cool thanks. Any idea of what "near future" means in terms of timing? I'm doing some development against the API now, so just wondering if it makes sense to essentially build my own wrapper or if I should just brute force it for now with standard curl calls via guzzle until this wrapper is ready for v2.
It is a requirement for me and my company to use API v2 very soon as well. I've started working on this project again. I cannot give you a deadline, but this is one of my highest priorities right now.
ok cool...then i'll hack for now until you're updated and then i'll pull it in. thanks!
I'm just curious, which version of the wrapper are you currently using @smenzer?
i actually forked your repo so i could set a release on the latest master code since it seemed more up-to-date. currently, though, i'm not using it since the v1x api isn't working for me, so I'm just going to do some manual curl calls for now w/o any wrapper.
OK 😉
Hii does this support zoho api v2.0?
Hi @dotshiteshsharma. Yes it supports API v2, but not in a stable version yet. If you are interested in giving it a go, you can checkout the v2-support branch. You can require it with Composer this way:
"tristanjahier/zoho-crm-php": "dev-v2-support"
It is subject to many breaking changes in the future, but if you want, you can lock the version number with a commit sha1 with Composer:
"tristanjahier/zoho-crm-php": "dev-v2-support#9f532dc2b4556837de02ab632dedb26b276eec5a"
(9f532dc2b4556837de02ab632dedb26b276eec5a
being the latest commit)
Unfortunately, the README.md
has not been updated yet for API v2. But I'll give you an example here:
$client = new Zoho\Crm\V2\Client('client id', 'client secret', 'refresh token');
$client->refreshAccessToken();
// Get all Deals records
$deals = $client->records->deals->all()->get();
// Get a single Contact by ID
$aDeal = $client->records->contacts->find('thelongzohoid');
Note that in this example, the access token is never stored persistently, this is why we have to refresh it manually at the beginning (that is not the correct way to handle the access token but here it is for the sake of simplicity).
Not every type of API request is yet supported via these fancy helpers. But you can perform any type of request using a "raw query":
use Zoho\Crm\Support\HttpMethod;
$response = $client->newRawQuery()
->setHttpMethod(HttpMethod::PUT)
->setUri('the/path?key=value&plop=tut')
->setHeader('toto', 'tutu')
->setBody('sdfnsdjhfjhkejhwehrjhwehjkr');
->execute();
Raw queries have no validation and no response processing.
Thank you very much for giving us a bit more insight - would also like to find out if you have an estimated timeline for when v2 support will be merged as stable.
Hi @vburghelea. The v2-support branch changed a lot since my last comment. It is now pretty stable and easier to use (with a better handling of the token persistency). I would like to make a release in like a month max. It would be v0.4 or v0.5.
Thank you for the update, @tristanjahier, greatly appreciated - I'll keep an eye on this, we're considering building our CRM on top of Zoho and using this library for abstraction.
@vburghelea nice! The library has received a lot of updates since my last code snippet, so if you want to tinker with it, here is the new recommended way to set up the API client:
// Create a file store to handle token persistence.
$tokenStore = new Zoho\Crm\V2\AccessTokenStores\FileStore('dev/.token.json');
$tokenStore->createUnlessExists();
$client = new Zoho\Crm\V2\Client(
'client id',
'client secret',
'refresh token',
$tokenStore
);
// Automatic token refresh, no need to deal with it manually anymore.
$client->preferences()->set('access_token_auto_refresh_limit', 60);
If you don't want to bother handling the token persistence, you can omit the token store:
$client = new Zoho\Crm\V2\Client('client id', 'client secret', 'refresh token');
but then, obviously, the token will be refreshed each time you run your script or your REPL.
Hello @smenzer, @dotshiteshsharma and @vburghelea!
I know that this is a very old issue 😅, but I'm glad to tell you that I have just released a new version (0.5
) which brings support for Zoho CRM API v2, improves compatibility with other Composer packages, and supports PHP 8.
Another important thing is that the package has a new name in packagist.org (the Composer repository). I dropped the -php
suffix because it felt redundant.
So you should update your composer.json
like so:
"require": {
"tristanjahier/zoho-crm": "^0.5"
}
Finally, the README.md is now up-to-date and explains how to get started with API v2.
It's not clear if this wrapper supports the new zoho api version 2.0, or only the deprecated 1.x version. Can you clarify, please?