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 »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Check if contact exists
Pages: 1 [2]

Author Topic: Check if contact exists  (Read 4073 times)

ilbassa

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 3.4.7
  • CMS version: Joomla 1.5
  • MySQL version: unknown
  • PHP version: 5.2.13
Re: Check if contact exists
November 14, 2011, 08:59:49 am
With 'Email' it works, but it search in civicrm_email table of the DB where are stored all the email even that ones that belongs to deleted contacts, so the maching isn't real.
If I have contact "a@a.it" and than i delete it, the

 $contact = civicrm_api('Email', 'Get', array('email' => $got_email, 'version' => '3'));

returns with

Array ( [is_error] => 0 [version] => 3 [count] => 1 [id] => 2895 [values] => Array ( [2895] => Array ( [id] => 2895 [contact_id] => 2826 [location_type_id] => 1 [email] => a@a.it [is_primary] => 1 [is_billing] => 0 [on_hold] => 0 [is_bulkmail] => 0 ) ) )

but in CiviCRM there isn't the contact that have this email...

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Check if contact exists
November 14, 2011, 10:24:54 am
Not that it will solve your problem, but deleted contacts are really there in the table, with the flag is_deleted, so the email is still there.

Anyway, it would be super useful to be able to get emails that belong to "not deleted" contacts indeed, but that's a long term project, if we decide to take it on.

For your immediate problems. Going back to the api.contact.get, so you can see it reaches the step just before the return in civicrm_api, but it doesn't reach the step just after your civicrm_api call?

(but works fine from the api explorer?)

How weird...

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

ilbassa

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 3.4.7
  • CMS version: Joomla 1.5
  • MySQL version: unknown
  • PHP version: 5.2.13
Re: Check if contact exists
November 15, 2011, 12:49:52 am
First of all I want to thanks you for trying to help me.

Api explorer: I visit this page index2.php?option=com_civicrm&task=civicrm/ajax/doc/api#explorer
I select "3" - "contact" - "get" - "debug" - "json"

and the result is
{
   "is_error":1,
   "error_message":"API permission check failed for Contact\/get call; missing permission: view all contacts."
}

and with V2 ( "2" - "contact" - "get" - "debug" - "json")
it displays some contacts

So It seems I have to set permission somewhere related to V3... any idea?

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Check if contact exists
November 15, 2011, 01:04:12 am
That your contact doesn't have the permission to access civicrm?

Or that you need to upgrade, some things might have been fixed recently
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

ilbassa

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 3.4.7
  • CMS version: Joomla 1.5
  • MySQL version: unknown
  • PHP version: 5.2.13
Re: Check if contact exists
November 15, 2011, 01:14:59 am
CiviCRM was reinstalled from scratch so I have the latest stable version (3.4.7 / 19-oct-2011)

Maybe there are some wrong permissions on the user that access the DB to query civicrm table? I'll ask my sys admin to check.

I need to understand the difference between v2 and v3 because v2 works...

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Check if contact exists
November 15, 2011, 01:27:14 am
For the API explorer it's your user that doesn't have the needed access (view all contacts)

For the civicrm call, don't know but definitely something to check.

The difference is night and day. The main difference you want to know is that v2 is end of lifed and will be removed soon ;)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

ilbassa

  • I’m new here
  • *
  • Posts: 11
  • Karma: 0
  • CiviCRM version: 3.4.7
  • CMS version: Joomla 1.5
  • MySQL version: unknown
  • PHP version: 5.2.13
Re: Check if contact exists
November 15, 2011, 04:03:56 am
The API explorer works (for error I visited the page from frontend), it results with a code html that seems to be the home of civicrm component.

If I put
Code: [Select]
echo 'aTest';
$mainframe->close();
in the civicrm_api() function in api/api.php, the page show the word so I think that the error is somewhere -after- the line.

I moved the 2 line of test after my line:
   $results=civicrm_api("Contact","get", array ('option' =>'com_civicrm', 'amp;task' =>'civicrm/ajax/rest', 'version' =>'3'));
and it works!!

If I write
Code: [Select]
$results=civicrm_api("Contact","get", array ('option' =>'com_civicrm', 'amp;task' =>'civicrm/ajax/rest', 'version' =>'3'));
print_r($results);
$mainframe->close();
the page shows my results... but if I remove "$mainframe->close();" it will show a blank page.. so it could be a problem regarding CiviCRM's api?

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Check if contact exists

This forum was archived on 2017-11-26.