11

Is there a way to view or generate a Contact's checksum via the REST API?

I'm looking to use the checksum to provide relevant form links, etc., but need to get it programmatically on a Contact basis. Any and all insight is appreciated. Thanks!

9

I have never seen the checksum available in the API.

I have successfully obtained it programmatically though with code similar to:

$cs = CRM_Contact_BAO_Contact_Utils::generateChecksum($contact_id);

(This snippet is adapted from core code in CRM/Utils/Token.php)

  • thanks for the lead. Unfortunately, my application is only able communicate via REST and doesn't have access to the core Civi application. Still, this lets me know that it is possible, if it isn't already apart of the REST spec. – mac Aug 12 '15 at 20:50
  • This would be incredibly useful via API. If a checksum is not currently available in the API, then has anyone explored what it would take to program this? If it is worth building and contributing to the community, or doing an MIH for it. – Daniel Ando Scholnick Aug 16 '15 at 20:44
9
+25

I'm pretty certain you can't get a checksum from the standard API. However, you should write (or commission) an extension to provide a checksum API. The API would basically be a wrapper around the code that DaveD suggested, and you can read documentation here on how to use Civix to generate an API in your extension.

  • 2
    Or it could be added as an action in the contact api. E.g. civicrm_api3('Contact', 'generatechecksum', array('id' => $cid)); and it might also be nice to have civicrm_api3('Contact', 'validatechecksum', array('id' => $cid, 'checksum' => 'abc123')); – Coleman Aug 17 '15 at 22:00
4

I needed this exact functionality, so I wrote the extension that provides it, com.megaphonetech.checksums. I used Coleman's comment above as my spec :)

  • Nice one Jon :) – Coleman Feb 12 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.