Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote CiviCRM? #1

Open
davidjosephhayes opened this issue Jun 25, 2022 · 8 comments
Open

Remote CiviCRM? #1

davidjosephhayes opened this issue Jun 25, 2022 · 8 comments
Labels
enhancement New feature or request

Comments

@davidjosephhayes
Copy link

Hello! This looks super cool. I installed on a test site this evening to try it out, but immediatly got an error: Call to undefined function GFCiviCRM\\civicrm_initialize(). Obviously, the plugin is currently intended for local CiviCRM installs but I was going to attempt a remote form submit.

Looks like development is happening fast. Would you be interested in some pull requests to add remote CiviCRM support?

@agileware-justin
Copy link
Contributor

@davidjosephhayes yes, go for it!

If you want to submit some documentation PRs as well, that would be super too.

@davidjosephhayes
Copy link
Author

Awesome! I'll circle back around as my project comes together. Thanks!

@davidjosephhayes
Copy link
Author

davidjosephhayes commented Jul 7, 2022

Speaking of documentation, I am a big confused how the webhook works with the settings detailed on #11 .

With the explanation given, I am seeing the webhook request body in the debugger as json similar to:

Array
(
    [body] => {"first_name":"John","last_name":"Doe","email":"[email protected]"}
    [method] => POST
    [headers] => Array
        (
            [Authorization] => Bearer **API_KEY**
            [X-Civi-Key] => **SITE_KEY**
            [X-Requested-With] => XMLHttpRequest
            [Content-Type] => application/json
        )

    [sslverify] => 1
)

And receiving an error response from CiviCRM.

{
  "fields": ["email", "first_name","last_name"],
  "error_code":"mandatory_missing",
  "entity":"FormProcessor",
  "action":"newsletter_subscribe",
  "is_error":1,
  "error_message":"Mandatory key(s) missing from params array: email, first_name, last_name"
} 

I am not too familiar with Form Processor specifically, but the API Explorer seems to indicate that it would like the json nested under a json variable in the request body. Similar to:

json=%7B%22first_name%22%3A%22John%22%2C%22last_name%22%3A%22Doe%22%2C%22email%22%3A%22jdoe%40example.com%22%7D

I can make a pull request to fix this if it is an issue, but I want to make sure I am not missing anything obvious first.

Thoughts?

@agileware-justin
Copy link
Contributor

@davidjosephhayes so I don't think a PR is required, because this works. It's more like the documentation is wrong or the example for form processor is wrong. They were based on a working environment, so should be OK.

Did you check that all the steps were done as per https://github.com/agileware/gf-civicrm/blob/main/README.md#setting-up-a-newsletter-subscription-form-using-gravity-forms-and-civicrm

And in particular, make sure the request URL in Gravity Forms, Web Form is correct.

@jaapjansma
Copy link

I have a project on which remote support is needed. I am happy to contribute to this plugin.

My approach would be:

  1. Make a wrapper function around civicrm_api3 and if function civicrm_api3 is available use that one, or use the function coming from https://github.com/CiviMRF/civimcrestface-wordpress
  2. Have additional settings to select the connection profile (which would also make the entering of api and site keys reduntant in the webhook settings screen of the form.

Two questions:

  1. Does my approach sound right? Step 2 could also be done as a separate thing.
  2. Do you accept pull requests with this functionality?

@agileware-fj
Copy link
Contributor

agileware-fj commented Oct 1, 2024

Hi @jaapjansma

Our original approach was very similar to what you propose here, as in the CMRF-experiment branch. Our concerns with this though is that the CMRF_Abstract_Core class and the mcrestface connector plugin introduces too much magic and too many layers of indirection, that we're not keen to do technical support on in the future.
We did use the connection profile feature of the mcrestface connector at one point.

So an API wrapper function sounds about right, although note we do have some APIv4 functions in there as well (Contact selection via SearchKit for example) - and would prefer to wrap APIv4 TBH and remove all the v3 code.
No so much using CMRF though due to the tech concerns and by extension not the connection profiles in the civimcrestface-wordpress plugin.

Otherwise we're happy to review pull requests for this function.

@jaapjansma
Copy link

Ah okay. I see, yes the CMRF_Abstact_Core is a bit abstract and complex to understand first. It is also from a technical point of view not the cleanest solution. I will probably develop something new then rather than fiddling with this extension.

@agileware-justin
Copy link
Contributor

@jaapjansma it would be good to collaborate to add remote CiviCRM support to this plugin, instead of creating a new plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

4 participants