CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • accessing hash values for a contact with v2 API
Pages: [1]

Author Topic: accessing hash values for a contact with v2 API  (Read 6071 times)

chrism

  • Guest
accessing hash values for a contact with v2 API
March 20, 2008, 07:01:35 pm
The civicrm_subscription Drupal module built on v1 API used a contact's hash value to send a unique link that the user can click to confirm subscription (storing a copy of the hash in the module's DB records).  It used the hash value in the contact object that was returned with:

   $contact =& crm_create_contact($params);
   $hash = $contact->hash;

I am stuck figuring out how to replicate this feature with v2 api. After creating a new contact
   $contact =& civicrm_contact_add($params);

then the array returned from contact_get does not included the hash.
   $params = array('id'=>$contact['contact_id']);
   $contact =& civicrm_contact_get($params);

What is the intended use of the contact hash value? Would just creating new random hash values in the module be a suitable approach? 

chrism

  • Guest
Re: accessing hash values for a contact with v2 API
March 22, 2008, 02:24:42 am
I have solved this by just creating new random hash values within the subscribe module.

I found the time-limited hash values implemented here:
http://issues.civicrm.org/jira/browse/CRM-1573
http://forum.civicrm.org/index.php/topic,2074.0.html
so this is might  be an approach to take in the future.


Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: accessing hash values for a contact with v2 API
March 24, 2008, 12:10:55 pm
Chris - On a related note, 1.9+ includes a built-in subscribe page which handles the double-opt-in (http://.../civicrm/mailing/subscribe?reset=1) - and you can add gid=x to it to limit to a specific mailing list group. Also there's a 2.1 issue to add the ability to include a Profile (e.g. other fields) in this form.

I'm wondering if this functionality is comparable to what you're using civicrm_subscription for ??
Protect your investment in CiviCRM by  becoming a Member!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: accessing hash values for a contact with v2 API
March 24, 2008, 02:31:44 pm
Quote from: chrism on March 20, 2008, 07:01:35 pm
then the array returned from contact_get does not included the hash.
   $params = array('id'=>$contact['contact_id']);
   $contact =& civicrm_contact_get($params);

You'll need to specifically ask for the contact hash value in the get request. The old api would return everything, which in turn made the object quite large (and involved way too many db queries)

Quote from: chrism on March 20, 2008, 07:01:35 pm
What is the intended use of the contact hash value? Would just creating new random hash values in the module be a suitable approach? 

creating new random hash values is fine. we just use it as a checksum in a few urls to ensure that the id and the hash match (i.e. folks cant change the id and modify the db without knowing the hash for the contact)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

chrism

  • Guest
Re: accessing hash values for a contact with v2 API
April 01, 2008, 12:45:18 am
Thanks for responses Dave, Lobo.

I had missed the new /mailing/subscribe feature so glad to know about it!

After looking at /mailing/subscribe it seems like the differences are just that the subscribe module collects FirstName LastName email, has conditional behaviour based on dupe checking, and has an option for new user account creation of either CiviCRM or CiviCRM + Drupal.  I'm not sure how folks use the CiviCRM + Drupal option.

I wrote an upgrade patch for the module, but I can see that with profile inclusion in 2.1 (great feature!), perhaps some conditional behaviour (e.g. let people know if they are already subscribed) and contact matching, the module may not be needed by most.

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: accessing hash values for a contact with v2 API
April 01, 2008, 04:31:26 am
Quote
After looking at /mailing/subscribe it seems like the differences are just that the subscribe module collects FirstName LastName email, has conditional behaviour based on dupe checking, and has an option for new user account creation of either CiviCRM or CiviCRM + Drupal.  I'm not sure how folks use the CiviCRM + Drupal option.

I think most of this functionality can be done using profiles except mailing subscription.

There is already v2.1 issue for this. http://issues.civicrm.org/jira/browse/CRM-2861

kurund

Found this reply helpful? Support CiviCRM

torenware

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 4
Re: accessing hash values for a contact with v2 API
April 06, 2008, 08:54:11 pm
Quote from: Kurund Jalmi on April 01, 2008, 04:31:26 am
Quote
After looking at /mailing/subscribe it seems like the differences are just that the subscribe module collects FirstName LastName email, has conditional behaviour based on dupe checking, and has an option for new user account creation of either CiviCRM or CiviCRM + Drupal.  I'm not sure how folks use the CiviCRM + Drupal option.

I think most of this functionality can be done using profiles except mailing subscription.

There is already v2.1 issue for this. http://issues.civicrm.org/jira/browse/CRM-2861

kurund


This was a little tweaky in 1.9;  we discovered it changed the current CRM user's email address as a  side effect.  Since we couldn't figure out how to turn this off, we couldn't use that feature.

Has this been fixed in 2.x?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: accessing hash values for a contact with v2 API
April 07, 2008, 12:24:28 am

I dont think its a side effect. For a logged in user, it basically updates the email address that the person subscribes to. Any specific reason you dont want that effect? Can you elaborate

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

pelicani

  • I’m new here
  • *
  • Posts: 24
  • Karma: 0
Re: accessing hash values for a contact with v2 API
May 05, 2009, 09:11:35 am
Quote from: Donald Lobo on March 24, 2008, 02:31:44 pm
You'll need to specifically ask for the contact hash value in the get request. The old api would return everything, which in turn made the object quite large (and involved way too many db queries)

How do you do this?
The module for subscribing in drupalv6 is in dev.
I'm modifying it so it works, but can't get the 'hash' return value.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: accessing hash values for a contact with v2 API
May 05, 2009, 10:01:14 am

activating old topic is not recommended

You might want to start a new topic and give details on what you've done, what works and what has not worked

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • accessing hash values for a contact with v2 API

This forum was archived on 2017-11-26.