-3

I really don’t have much information about rest api, or api or anything about sending and getting informations from CMSs to another. but recently I’ve got a php CRM called “Perfex” and I want to connect it to my wordpress website, so new orders would be stored in my CRM orders, new customers will be saved as new customers in my CRM, but I don’t know how to do it, I’ve searched for a week, and I found there is a module:

https://perfexcrm.themesic.com/apiguide/index.html

I got that, and I don’t know how to use it. is it possible to use it on my cpanel shared hosting? or I need to use a virtual machine?

help me please.

  • Does this answer your question? [Call a REST API in PHP](https://stackoverflow.com/questions/9802788/call-a-rest-api-in-php) – Daniel W. Aug 04 '20 at 13:56
  • I already know that I can use it through cURL php extension, but the problem is that I don't know how to do it, do I need to write a file? where should I call it? how to do this calling to be connected with wordpress? – Natasun Company Aug 04 '20 at 14:00
  • You probably need to write several files if you want to do it the good way. – Daniel W. Aug 04 '20 at 15:03
  • would you please help me writing one of those? and then I will learn how to do the next files, – Natasun Company Aug 04 '20 at 15:14
  • No. Go to GitHub and look at one of those billions of example there. Maybe try learning PHP basics before trying to implement a complex webservice. – Daniel W. Aug 04 '20 at 15:22

1 Answers1

0

Welcome to stackoverflow!

You'll essentially need to research what is an API and how to send requests to the API.

You will need to write some PHP code that executes at the creation of an order in your WordPress site. See link below:

How to use an API with PHP

To detect when an order is created on your WordPress site, check the following links:

Call a function after checkout

Call a function after order status is set to complete

The code can be added to your functions.php although that is not recommended since updating your parent theme will remove all code. You could create a child theme or add the code to a Code Snippet

haidousm
  • 556
  • 6
  • 21
  • thank you haidousm, I actually searched a lot, but the fact is that I already know that I can use it through cURL php extension, but the problem is that I don't know how to do it, do I need to write a file? where should I call it? how to do this calling to be connected with wordpress? I think my question is more related to the CRM I've got, but I don't know how to use the api to connect it with wordpress. – Natasun Company Aug 04 '20 at 14:03
  • Check the edits above. You will need to write a file and/or a code snippet on your WordPress site which will make an API request to your CRM (through cURL) and pass in the data pertaining to the order just created on your WordPress site. – haidousm Aug 04 '20 at 14:05
  • Thank you, I've installed Code Snippet now, sorry for being so newcomer, I actually don't know anything, just trying to start to learn. I need someone to help me. I've added the code from "Call a function after checkout" to my snippet code, but I don't know how it can be connected to my CRM, please read the link I shared, is a documentation of the module, how is it possible to use "curl -H " in my snippet? let's say I want to send my contact form 7 submits as a lead to my CRM, how can I write a snippet code for that? please help. Thanks. – Natasun Company Aug 04 '20 at 14:18
  • Do not be sorry for not knowing! We all are still learning. Here's how your flow should be: Get data from ContactForm7 after submission -> Create a POST request to the `api/leads` as per the CRMs documentation. [Call a REST API in PHP](https://stackoverflow.com/questions/9802788/call-a-rest-api-in-php) might help you with your POST request. I also found the following blog post that might be what you need: [WordPress > Perfex CRM](https://perfex.dev/en/wordpress-perfex-crm-2/) – haidousm Aug 04 '20 at 14:28
  • thanks haidosm, I actually used first the first link you send, created a code but it seems to be invalid, the second link I've already done that but this is only when I buy a module with their website, I already have the official module created by developer. the problem for me is the coding now. I don't know how I can send the code to review. – Natasun Company Aug 04 '20 at 14:42
  • I also used Postman app, but the error I get is: 405 method not allowed. – Natasun Company Aug 04 '20 at 14:53
  • this line: https://my.mywebsite.ir/admin/api/leads?authtoken=CODE&source=1&status=1&name=name&assigned=1 – Natasun Company Aug 04 '20 at 15:05