Changeset 2530005
- Timestamp:
- 05/11/2021 08:23:35 PM (5 years ago)
- Location:
- integrate-sharpspring-and-gravity-forms/trunk
- Files:
-
- 2 edited
-
class-integrate-sharpspring-and-gravity-forms.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
integrate-sharpspring-and-gravity-forms/trunk/class-integrate-sharpspring-and-gravity-forms.php
r2522883 r2530005 225 225 * Initialize API. 226 226 */ 227 public function initialize_api( ) {227 public function initialize_api() { 228 228 // Send a request to verify credentials. 229 229 $params = array( 'where' => array(), 'limit' => 0, 'offset' => 0 ); 230 230 $results = $this->sharpspring_post( $params, 'getActiveLists' ); 231 $results = json_decode($results['body'], true); 232 233 // If the account id or both the id and secret are incorrect the api will only return a string. 234 // This will check if the secret key is valid if the account id is correct. 235 $error_code = ''; 236 if( $results != 'Invalid Api Key' ) { 237 $error_code = $results['error']['code']; 238 } 239 return $error_code || $results == 'Invalid Api Key' ? false : true; 231 232 // Check to make sure the secret key is valid 233 $secret_results = json_decode($results['body'], true); 234 235 // 104 = Header missing Secret Key 236 // 105 = User authentication failed 237 $error_code = isset($secret_results['error']) ? $secret_results['error']['code'] : ''; 238 $error_msg = isset($secret_results['error']) ? $secret_results['error']['message'] : ''; 239 240 // If the secret key response returns either a 104 or 105 return false 241 if ( $error_code === 104 || $error_code === 105 ) { 242 return false; 243 } 244 245 // Check to make sure the Account ID is valid 246 $id_results = $results['response']; 247 248 // If the response returns unathorized return false 249 if( $id_results['code'] === 401 ) { 250 return false; 251 } 252 253 // If the Account ID & Secret Key are valid return true 254 return true; 240 255 } 241 256 … … 382 397 return false; 383 398 } 384 385 399 386 400 // Retrieve the name => value pairs for all fields mapped in the 'mappedFields' field map. … … 422 436 $lead_results = json_decode($lead_results['body'], true); 423 437 $lead_id = $lead_results['result']['lead'][0]['id']; 438 439 // If lead already exists, update the lead's information 440 $lead_updated = $this->sharpspring_post( $params, 'updateLeads' ); 424 441 } else { 425 442 $lead_id = $lead_post['result']['creates'][0]['id']; … … 429 446 $list_id = rgars( $feed, 'meta/sharpspring_list' ); 430 447 $params = array( 'listID' => $list_id, 'memberID' => $lead_id ); 448 431 449 $list_post = $this->sharpspring_post( $params, 'addListMembers' ); 432 450 } -
integrate-sharpspring-and-gravity-forms/trunk/readme.txt
r2522883 r2530005 39 39 == Changelog == 40 40 41 = 1.0.3 = 42 *Release Date - 11 May 2021* 43 44 * New - Added support for updateLeads method. This addition will update a lead's information if the lead already exists. 45 * Fixed - PHP notices that appeared when the Account ID was incorrect. 46 41 47 = 1.0.2 = 42 48 *Release Date - 28 April 2021*
Note: See TracChangeset
for help on using the changeset viewer.