Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Tiny lib for amoCRM API

License

NotificationsYou must be signed in to change notification settings

KikyTokamuro/Amoapi

Repository files navigation

Tiny lib foramoCRM API

This is DEV version of library so Author is not responsible of any damage, both direct and indirect,that may cause using of this library.

Installing

For installing add this to yourcomposer.json:

"minimum-stability":"dev","repositories": [    {"type":"vcs","url":"git@github.com:KikyTokamuro/Amoapi"    }],"require": {"kikytokamuro/amoapi":"dev-origin/dev"}

And run command:

composer require kikytokamuro/amoapi

What is implemented

Examples

Tokens

When receiving tokens, they are written to "tokens.json".

Which can be set via:

$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url","tokens.json"// <---);

tokens.json:

{"access_token":"access_token","refresh_token":"refresh_token","expires_in":86400,"receipt_date":1626683782,"expires_date":1626770182}

Get access and refresh tokens by code

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$tokens =$client->getTokensByCode("code");// arrayprint_r($tokens);}catch (AmoapiException$e) {echo$e;}

Get access and refresh tokens by refresh token

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$tokens =$client->getTokensByRefreshToken("refreshToken");// arrayprint_r($tokens);}catch (AmoapiException$e) {echo$e;}

Leads

Get 5 leads from 1 page

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$filter = ["page" =>0,"limit" =>5];try {$leads =$client->leads()->getAll($filter);// arrayprint_r($leads);}catch (AmoapiException$e) {echo$e;}

Get lead by id

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$lead =$client->leads()->getById(28091207);// array}catch (AmoapiException$e) {echo$e;}

Update lead

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$lead =$client->leads()->getById(28091207);// array}catch (AmoapiException$e) {echo$e;}$lead["name"] ="new name";$lead["price"] =1111;try {print_r($client->leads()->update([$lead]));// array}catch (AmoapiException$e) {echo$e;}

Create new lead

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$lead = [["name" =>"new lead","price" =>1111]];try {print_r($client->leads()->createNew($lead));// array}catch (AmoapiException$e) {echo$e;}

Add note to lead by id

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$note = ["note_type" =>"common","text" =>"test note"];try {print_r($client->leads()->addNoteById(28091207,$note));}catch (AmoapiException$e) {echo$e;}

Tasks

Get 50 tasks from 1 page

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$filter = ["page" =>0,"limit" =>50 ];try {$tasks =$client->tasks()->getAll($filter);// arrayprint_r($tasks);}catch (AmoapiException$e) {echo$e;}

Create task for others entity

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$task = ["task_type_id" =>1,"text" =>"Test task for 28144531","complete_till" =>1588885140,"entity_id" =>28144531,"entity_type" =>"leads","request_id" =>"example"];try {print_r($client->tasks()->createNew($task));}catch (AmoapiException$e) {echo$e;}

Contacts

Get all contacts

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$filter = ["page" =>0,"limit" =>50];try {$contacts =$client->contacts()->getAll($filter);// arrayprint_r($contacts);}catch (AmoapiException$e) {echo$e;}

Get contact by id

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$contact =$client->contacts()->getById(45552657);// arrayprint_r($contact);}catch (AmoapiException$e) {echo$e;}

Update contact

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$contact =$client->contact()->getById(28091207);// array}catch (AmoapiException$e) {echo$e;}$contact["name"] ="new name";$contact["price"] =1111;try {print_r($client->contacts()->update([$contact]));// array}catch (AmoapiException$e) {echo$e;}

Create new contact

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$contact = [["name" =>"new contact"]];try {print_r($client->contacts()->createNew($contact));// array}catch (AmoapiException$e) {echo$e;}

Add note to contact by id

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$note = ["note_type" =>"common","text" =>"test note"];try {print_r($client->contacts()->addNoteById(28091207,$note))}catch (AmoapiException$e) {echo$e;}

Companies

Get all companies

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$filter = ["page" =>0,"limit" =>50];try {$companies =$client->companies()->getAll($filter);// array;print_r($companies);}catch (AmoapiException$e) {echo$e;}

Get company by id

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$company =$client->companies()->getById(45607457);// arrayprint_r($company);}catch (AmoapiException$e) {echo$e;}

Update company

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$company =$client->companies()->getById(45607457);// array}catch (AmoapiException$e) {echo$e;}$company["name"] ="update company";try {print_r($client->companies()->update([$contact]));// array}catch (AmoapiException$e) {echo$e;}

Create new company

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$company = [["name" =>"new company"]];try {print_r($client->companies()->createNew($company));// array}catch (AmoapiException$e) {echo$e;}

Add note to company by id

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$note = ["note_type" =>"common","text" =>"test note"];try {print_r($client->companies()->addNoteById(45607457,$note));}catch (AmoapiException$e) {echo$e;}

Customers

Get all customers

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$filter = ["page" =>0,"limit" =>50];try {$customers =$client->customers()->getAll($filter);// arrayprint_r($customers);}catch (AmoapiException$e) {echo$e;}

Get customer by id

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$customer =$client->customers()->getById(183435);// arrayprint_r($customer);}catch (AmoapiException$e) {echo$e;}

Update customer

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$customer =$client->customers()->getById(183435);// array}catch (AmoapiException$e) {echo$e;}$customer["name"] ="update customer";try {print_r($client->customers()->update([$customer]));// array}catch (AmoapiException$e) {echo$e;}

Create new customer

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$customer = [["name" =>"new company"]];try {print_r($client->customers()->createNew($customer));// array}catch (AmoapiException$e) {echo$e;}

Add note to customer by id

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$note = ["note_type" =>"common","text" =>"test note"];try {print_r($client->customers()->addNoteById(183435,$note));}catch (AmoapiException$e) {echo$e;}

Users

Get all users

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$filter = ["page" =>0,"limit" =>50];try {$users =$client->users()->getAll($filter);// arrayprint_r($users);}catch (AmoapiException$e) {echo$e;}

Get user by id

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$user =$client->users()->getById(6928032);// arrayprint_r($user);}catch (AmoapiException$e) {echo$e;}

Roles

Get all users roles

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$filter = ["page" =>0,"limit" =>50];try {$roles =$client->roles()->getAllRoles($filter);// arrayprint_r($roles);}catch (AmoapiException$e) {echo$e;}

Get role by id

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$role =$client->roles()->getRoleById(56320);// arrayprint_r($role);}catch (AmoapiException$e) {echo$e;}

Account

Get account info

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$info =$client->account()->getInfo();// arrayprint_r($info);}catch (AmoapiException$e) {echo$e;}

Catalogs

Get all catalogs

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$filter = ["page" =>0,"limit" =>50];try {$catalogs =$client->catalogs()->getAll($filter);// arrayprint_r($catalogs);}catch (AmoapiException$e) {echo$e;}

Get catalog by id

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$catalog =$client->catalogs()->getById(2419);// arrayprint_r($catalog);}catch (AmoapiException$e) {echo$e;}

Create new catalog

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$catalog = [["name" =>"new catalog"]];try {print_r($client->catalogs()->createNew($catalog));// array}catch (AmoapiException$e) {echo$e;}

Update catalog

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$catalog =$client->catalogs()->getById(2419);// array}catch (AmoapiException$e) {echo$e;}$catalog["name"] ="update catalog";try {print_r($client->catalogs()->update([$catalog]));// array}catch (AmoapiException$e) {echo$e;}

Get all catalog elements

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$filter = ["page" =>0,"limit" =>50];try {$elements =$client->catalogs()->getAllElements(1989,$filter);// arrayprint_r($elements);}catch (AmoapiException$e) {echo$e;}

Get catalog element by id

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$element =$client->catalogs()->getElementById(1989,953789);// arrayprint_r($element);}catch (AmoapiException$e) {echo$e;}

Add new element to catalog

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}$element = [["name" =>"new element"]];try {print_r($client->catalogs()->createNewElement(1989,$catalog));}catch (AmoapiException$e) {echo$e;}

Update catalog element

useAmoapi\Client\AmoapiClient;useAmoapi\Exception\AmoapiException;$client =newAmoapiClient("subdomain","client_id","client_secret","redirect_url",);try {$client->getTokensByCode("code");}catch (AmoapiException$e) {echo$e;}try {$element =$this->client->catalogs()->getElementById(1989,953789);}catch (AmoapiException$e) {echo$e;}$element["name"] ="new name";// Delete not expected fieldsunset($element["created_by"]);unset($element["updated_by"]);unset($element["custom_fields_values"][2]["values"][0]["enum_code"]);try {print_r($this->client->catalogs()->updateElement(1989, [$element]));}catch (AmoapiException$e) {echo$e;}

About

Tiny lib for amoCRM API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp