GroCRM.php
Initial Release
Gro CRM SDK를 사용하면 PHP의 Gro CRM REST API에 쉽게 연결할 수 있습니다.
Gro CRM SDK를 사용하면 연락처, 작업, 거래, 인벤토리 등을 관리 할 수 있습니다!
이 프레임 워크를 설치하는 권장 방법은 작곡가를 통해입니다.
composer require grocrm/grocrm
fields 에서 허용되는 매개 변수, 각 방법에서 반환되는 응답 값 등에 대한 추가 정보는 Gro CRM 문서를 방문하십시오.
<?php
require " vendor/autoload.php " ;
use GroCRM Client
$ client = new Client ( " gro_crm_api_key " ); // Return the contacts api class
$ contacts = $ client -> contacts ();
// Return contact types or a single type with id
$ contactTypes = $ contacts -> types ( $ id = null );
// Create a contact
$ newContact = $ contacts -> create (array $ fields );
// Return a list of contacts
$ allContacts = $ contacts -> getAll ( $ page = 1 , $ per_page = 20 , $ search = null , $ sort = " date " , $ order = " desc " );
// Return the contact with the specified id
$ contact = $ contacts -> get ( $ id );
// Return the contacts associated with the specified contact id
$ associatedContacts = $ contacts -> getAssociatedContacts ( $ id , $ page = 1 , $ per_page = 20 , $ search = null , $ sort = " date " , $ order = " desc " );
// Return the deals associated with the specified contact id
$ associatedDeals = $ contacts -> getAssociatedDeals ( $ id , $ page = 1 , $ per_page = 20 , $ search = null , $ sort = " date " , $ order = " desc " );
// Return the tasks associated with the specified contact id
$ associatedTasks = $ contacts -> getAssociatedTasks ( $ id , $ page = 1 , $ per_page = 20 , $ search = null , $ sort = " date " , $ order = " desc " );
// Update the contact with the specified id
$ updatedContact = $ contacts -> update ( $ id , array $ fields );
// Delete the contact with the specified id
$ contacts -> delete ( $ id ); // Return the deals api class
$ deals = $ client -> deals ();
// Return deal sources or a single source with id
$ dealSources = $ deals -> sources ( $ id = null );
// Return deal stages or a single stage with id
$ dealStages = $ deals -> stages ( $ id = null );
// Return deal scores or a single score with id
$ dealScores = $ deals -> scores ( $ id = null );
// Create a deal
$ newDeal = $ deals -> create (array $ fields );
// Return a list of deals
$ allDeals = $ deals -> getAll ( $ page = 1 , $ per_page = 20 , $ search = null , $ sort = " date " , $ order = " desc " );
// Return the deal with the specified id
$ deal = $ deals -> get ( $ id );
// Update the deal with the specified id
$ updatedDeal = $ deals -> update ( $ id , array $ fields );
// Delete the deal with the specificed id
$ deals -> delete ( $ id ) // Return the tasks api class
$ tasks = $ client -> tasks ();
// Return task statuses or a single status with id
$ taskStatuses = $ tasks -> statuses ( $ id = null );
// Return task priorities or a single priority with id
$ taskPriorities = $ tasks -> priorities ( $ id = null );
// Return task scores or a single scores with id
$ taskScores = $ tasks -> scores ( $ id = null );
// Create a task
$ newTask = $ tasks -> create (array $ fields );
// Return a list of tasks
$ allTasks = $ tasks -> getAll ( $ page = 1 , $ per_page = 20 , $ search = "" , $ sort = " date " , $ order = " desc " )
// Return the task with the specified id
$ task = $ tasks -> get ( $ id )
// Update the task with the specified id
$ updatedTask = $ tasks -> update ( $ id , array $ fields )
// Delete the task with the specified id
$ tasks -> delete ( $ id ) // Return the inventory api class
$ inventory = $ client -> inventory ();
// Return inventory types or a single type with id
$ inventoryTypes = $ inventory -> types ( $ id = null );
// Create a new inventory item
$ newInventoryItem = $ inventory -> create (array $ fields );
// Return a list of inventory items
$ allInventory = $ inventory -> getAll ( $ page = 1 , $ per_page = 20 , $ search = "" , $ sort = " date " , $ order = " desc " );
// Return the inventory item with the specified id
$ inventoryItem = $ inventory -> get ( $ id );
// Update the inventory item with the specified id
$ updatedInventoryItem = $ inventory -> update ( $ id , array $ fields );
// Delete the inventory item with the specified id
$ inventory -> delete ( $ id ); // Return the company api class
$ company = $ client -> company ();
// Return your companies information
$ companyInfo = $ company -> get ();
// Update your companies information
$ updatedCompanyInfo = $ company -> update (array $ fields ); // Return the user api class
$ users = $ client -> users ();
// Return user roles or a single role with id
$ userRoles = $ users -> roles ( $ id = null );
// Return a list of users
$ allUsers = $ users -> getAll ( $ page = 1 , $ per_page = 20 , $ search = "" , $ sort = " date " , $ order = " desc " );
// Return a user with the specified id
$ user = $ users -> get ( $ id );
// Return the currently authenticated user
$ authenticatedUser = $ users -> getAuthenticated (); // Return countries or a single country with id
$ countries = $ client -> getCountries ( $ id = null );
// Return timezones or a single timezone with id
$ timezones = $ client -> getTimeszones ( $ id = null );
// Return currenciesor a single currency with id
$ currencies = $ client -> getCurrencies ( $ id = null );여러 항목을 반환하는 메소드는 호출기 클래스를 사용하여 여러 페이지의 데이터를 통해 Pagination을 사용할 수 있습니다.
$ contactsPage1 = $ client -> contacts ()-> getAll ();
$ pager = new GroCRM API Pager ( $ client , $ contacts );
if ( $ pager -> hasNext ()) {
$ contactsPage2 = $ pager -> getNext ();
}Gro CRM SDK는 모든 네트워크 요청에 Guzzle을 사용합니다. 요청을 시도하고 요청에 실패하면 Guzzle 예외가 발생합니다. Guzzle 예외에 대한 자세한 내용은 Guzzle Docs를 참조하십시오.
try {
$ contacts = $ client -> contacts ()-> getAll ();
var_dump ( $ contacts );
} catch ( GuzzleHttp Exception ClientException $ e ) {
$ response = $ e -> getResponse ();
$ statusCode = $ response -> getStatusCode ();
$ body = $ response -> getBody ()-> getContents ();
$ errors = json_decode ( $ body , true );
var_dump ( $ errors );
}도움이 필요한 경우 [email protected]으로 문의하거나 stackoverflow (태그 'grocrm')에 대한 질문을하십시오.
버그를 찾았습니까? 문제를여십시오