eugeneb 50 Posted September 28, 2018 Report Share Posted September 28, 2018 To anyone interested. I have long since been looking for an elegant solution for integrating another more flexible form-tool for WordPress with X2CRM. Some other guys tried developing WordPress plugins but I was never able to work with that. I extensively started using Gravity Forms (GF) on all my and customer sites due to its incredible flexibility and ease of use. Using GF I tend to always ask the contact details and then my custom field, which I don't always need in X2, but would like to capture the contact and maybe do some cool automation stuff. I tent to prefer not to hard code, to avoid custom dependency. I found a great and elegant solution for this and it works great. Using Gravity forms there is a little known GF plugin called SEND TO THIRD PARTY. This simplifies the RestAPI POST call by giving you a simple plkug and play type page with additional GF settings. Install the plugin in WordPress and in Gravity forms you can easily set it up to post to X2CRM by completing some key fields. I initially had a problem accessing my API which I was able to solve on this forum thread: http://community.x2crm.com/topic/3680-testing-my-api-but-not-getting/ So now I can use GF fully and send the contact and fields info over to X2CRM. Adding tags directly, making lists and using X2Flow Record Create triggers do even more with the new record comming in from GF. I hope this helps someone else that also wants to use Gravity Forms for more advanced form features on your website. 6 Quote Link to post Share on other sites
Attila 30 Posted October 1, 2018 Report Share Posted October 1, 2018 Nice one Eugene thank you 1 Quote Link to post Share on other sites
Ward@HRTechAdvisor.com 0 Posted February 1, 2019 Report Share Posted February 1, 2019 Thanks for sharing Eugene!Does Gravity Forms also let you pull data from X2 via API or only push?If only push, can you recommend a form tool that goes both ways? Quote Link to post Share on other sites
eugeneb 50 Posted February 4, 2019 Author Report Share Posted February 4, 2019 Hi Ward, both X2 and Gravity forms have Rest API's so you can do any integration either direction with both from a programmatic point of view. However, the Wordpress Gravity plugin I use to make the integration just quicker is one directional in my usecase. Thus pushing from Gravity to X2. I haven't investigated the more complex application for that plugin. It does have GET functions so maybe it can pull info from X2. Quote Link to post Share on other sites
alt_f4 57 Posted February 25, 2019 Report Share Posted February 25, 2019 Hi Eugene I´m just testing "your" solution. Can you post the settings and/or an example screenshot og the WP-backend with the settings used? Seems it won´t work on my site :-( My settings: generala.) your ".htaccess"WP backendb.) API connection: method. POSTc.) Auth: basic (username/password with API credentiols)d.) headers: nothinge.) API parameters: Format: defaultf.) MAP: email -> E-Mail Should work, hmmm? Any tipps?Screen: https://www.bilder-upload.eu/bild-10cea5-1551098178.png.html Regards! 1 Quote Link to post Share on other sites
chad1964 2 Posted February 25, 2019 Report Share Posted February 25, 2019 I have the same settings as alt_f4 above and with no luck either - anyone willing to shed some light on this I would be grateful - ty 1 Quote Link to post Share on other sites
eugeneb 50 Posted February 26, 2019 Author Report Share Posted February 26, 2019 Hi guys, sorry for the late reply. Lets see if we can fix this. From what I can see I still have some things different which will make a difference. You need to create some fields in Gravity with default values. These values you then need to put into the relevant fields of the 3rd party plugin. They are separate from the user fields you need the client to complete. GF Fields: I usually separate and Group my fields on Gravity Forms to know what they do. I have attached screenshots (Shots 1-3) to show you. First I group SETTING type fields and then any other fix values I want to pass through I put in FIELDS group. All these fields are on the Gravity form with default values, but hidden from the end-user. By doing this you can use these values in your 3rd party app. You can see the default values I have in the fields in grey. 3RD PARTY PLUGIN: You will need to setup like I have in my screenshot. Especially the Content-type. If setup in the field, then you can use this in the header also. The final screenshot shows how I mapped all fields and Header setting. If your .htaccess file is setup right, this should pass through. Remember to include the Visibility and AssignTo fields as compulsory seeing as just creating a user via the API will leave these field nulled thus your contact wont show in X2 front-end even if it was created in the X2 DB. By setting the Visibility and Assignto values your contact will show. Let me know if you guys get it right. 1 Quote Link to post Share on other sites
alt_f4 57 Posted February 26, 2019 Report Share Posted February 26, 2019 Hi Eugene 1000 Works like a warm summer breeze... Regards! 1 Quote Link to post Share on other sites
robert.keir 7 Posted April 26, 2019 Report Share Posted April 26, 2019 Hi Eugene, This is great! We have a separate application that does not use GF. Do you perhaps have the PHP code for what you did in your example above? Nice to see you the other day! Thanks,Rob 1 Quote Link to post Share on other sites
robert.keir 7 Posted April 26, 2019 Report Share Posted April 26, 2019 Hi All, We are trying to use restful API to create a new opportunity using version 7.0 of x2crm. Can someone comment on our PHP code below (I've changed the URL Address): <?php $request = new HttpRequest();$request->setUrl('http://xxxxxxx/index.php/api2/Opportunities/');$request->setMethod(HTTP_METH_POST); $request->setQueryData(array( 'assignedTo' => 'Anyone', 'c_Assigned_Dealer' => '1', 'Name' => '1', 'updatedBy' => 'Anyone', 'visibility' => '1')); $request->setHeaders(array( 'Connection' => 'keep-alive', 'content-length' => '', 'accept-encoding' => 'gzip, deflate', 'cookie' => 'PHPSESSID=v6ni4nvrfs1p5bma80qcs6v2s3', 'Host' => 'www.xxxx.co.za', 'Accept' => '*/*', 'User-Agent' => 'PostmanRuntime/7.11.0', 'Authorization' => 'Basic YWRtaW46VG0zQlU5d1Fvd3pWVjd4UTZ3NkI0R2p6N3N4WWRsdUw=', 'Content-Type' => 'application/json')); try { $response = $request->send(); echo $response->getBody();} catch (HttpException $ex) { echo $ex;} We keep getting the following error: { "httpHeaders": { "Content-Type": "application/json; charset=utf-8" }, "reqHeaders": { "Content-Length": "0", "Content-Type": "application/json", "Accept": "*/*", "Accept-Encoding": "gzip, deflate", "Authorization": "Basic YWRtaW46VG0zQlU5d1Fvd3pWVjd4UTZ3NkI0R2p6N3N4WWRsdUw=", "Connection": "keep-alive", "Cookie": "PHPSESSID=v6ni4nvrfs1p5bma80qcs6v2s3", "Host": "www.xxxxx.co.za", "User-Agent": "PostmanRuntime/7.11.0" }, "message": "Missing or malformed data sent to server.", "error": true, "status": 400} Any help would be appreciated. Thank you. 1 Quote Link to post Share on other sites
eugeneb 50 Posted April 29, 2019 Author Report Share Posted April 29, 2019 Hi Rob, nice to see you guys the other day. I don't have PHP code for our method as I am using a plugin. What are you using to check you code and info sent to the API? We used Postman and worked it through until it all worked. We also got Error 400's and gradually sorted the fields in the plugin. Without PHP. Also check your htaccess. file to make sure the info is passing through to X2. Thanks unfortunately all I can help with. Keep me posted. Quote Link to post Share on other sites
robert.keir 7 Posted April 29, 2019 Report Share Posted April 29, 2019 Hi Eugene, We use postman - works nicely with Get request. When we want to Put - error 400. We check that all mandatory fields are correct and have values. Would it be PHP not passing the request through from another location other than the server it is located on? I'll email X2crm and see if there is anything they can advise on. Do you know what setting would possibly be the culprit here? Deny-all or something like that? Will keep you posted. Quote Link to post Share on other sites
eugeneb 50 Posted April 29, 2019 Author Report Share Posted April 29, 2019 Our problem was also security between servers. Not sure if you saw my thread about the .htaccess file. After hours of searching and trialing it turned out the htaccess file was the culprit. Who knows, maybe its the same for yours. http://community.x2crm.com/topic/3680-testing-my-api-but-not-getting/ Quote Link to post Share on other sites
robert.keir 7 Posted April 29, 2019 Report Share Posted April 29, 2019 Thank Eugene - I"m going to have a look and give feedback. Quote Link to post Share on other sites
robert.keir 7 Posted May 2, 2019 Report Share Posted May 2, 2019 It turned out that it had nothing to do with .htaccess for us. Here is the sample code that I found on the community forum (http://community.x2crm.com/topic/2237-basic-test-for-web-lead-capture-missing-or-malformed-data-sent-to-server-400/) which I adapted for it to work from any server to our server. ===============================================//Assign values$firstName = $name;$lastName = "$lastname";etc... //create array$username = "USER";$password = "API_USER_KEY";$contact = array( "firstName" => $firstName, "lastName" => $lastName, "email" => $email, "leadSource" => $leadSource, "city" => $city, "c_Quoted_Brand" => $c_Quoted_Brand, "c_Instant_Quote_Status" => $c_Instant_Quote_Status, "c_Quote_no" => $c_Quote_no, "c_Unit" => $c_Unit, "phone" => $phone, "state" => $state, "description" => $notes, "assignedTo" => "Anyone", "updatedBy" => "Anyone", "visibility" => 1);$ch = curl_init();curl_setopt($ch, CURLOPT_URL,"http://www.SITE.co.za/index.php/api2/X2Leads");curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json; charset=utf-8;")); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password); $data = json_encode ($contact);curl_setopt($ch, CURLOPT_POST, $data);curl_setopt($ch, CURLOPT_POSTFIELDS, $data);curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLINFO_HEADER_OUT, true); //Actual Call to Server$server_output = curl_exec ($ch);===================================================== Works like a charm. Just need to update the username, API key, variables in the array and then the URL for the module. I saw the last time the API document was updated was on the 21st Dec 2015. Is there perhaps a newer version? Does the API allow for PDF document uploads? Thanks,Rob Quote Link to post Share on other sites
alt_f4 57 Posted November 17, 2020 Report Share Posted November 17, 2020 Hi Eugene, On our website the appatchments fails (guess since some weeks), using currect WP and GF. Did you (or anybody else) notice any error on your website? Regards! Quote Link to post Share on other sites
eugeneb 50 Posted November 18, 2020 Author Report Share Posted November 18, 2020 Hi Alt+F4, I havent tested and I havent seen anything broken. But will have a look. Quote Link to post Share on other sites
alt_f4 57 Posted November 18, 2020 Report Share Posted November 18, 2020 Thanks Eugene, I´ll try to figure it out from my site. The WP plugin (send to 3rd party) I´m using seems to be the last version 1.5.0. And I dont´see any error in the apache/php/firewall log. Arrrrgh. Keep care. Quote Link to post Share on other sites
eugeneb 50 Posted November 18, 2020 Author Report Share Posted November 18, 2020 Have you turned on the log in Gravity to see where it creates a problem. BTW what is the problem. Is it not pushing through to X2 any data? Quote Link to post Share on other sites
alt_f4 57 Posted November 18, 2020 Report Share Posted November 18, 2020 No entries in the log :-( and you´re right, nothing is pushed to X2. Quote Link to post Share on other sites
alt_f4 57 Posted November 18, 2020 Report Share Posted November 18, 2020 A big thank you, Eugene, and even a bigger sorry... my provider (Cloudways) has automatically recognized the cross-posting (X2 runs on a different server than the web server) as a security problem and prevented it by the firewall. I have now manually added the action / IP to the whitelist. Works again :-) 1 Quote Link to post Share on other sites
eugeneb 50 Posted November 18, 2020 Author Report Share Posted November 18, 2020 Great to hear Quote Link to post Share on other sites
hintditte 1 Posted April 16 Report Share Posted April 16 Thanks for sharing Eugene! Mobdro 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.