Created
January 10, 2017 21:17
-
-
Save gabrielkoerich/34e57cd095ed18709487a117871a9e81 to your computer and use it in GitHub Desktop.
Bulldesk PHP integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function input($name) | |
| { | |
| if (isset($_POST[$name])) { | |
| return $_POST[$name]; | |
| } | |
| } | |
| function post($url, $data) | |
| { | |
| $ch = curl_init(); | |
| curl_setopt($ch, CURLOPT_URL, $url); | |
| curl_setopt($ch, CURLOPT_POST, 1); | |
| curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); | |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
| $server_output = curl_exec ($ch); | |
| curl_close ($ch); | |
| } | |
| $name = input('name'); | |
| $from = input('email'); | |
| $phone = input('phone'); | |
| $message = input('message'); | |
| $token = input('token'); | |
| if (!$name || !$from || !$message || !$token) { | |
| http_response_code(422); | |
| die('Invalid'); | |
| } | |
| post('https://bulldesk.com.br/api/conversion', array( | |
| 'token' => 'token', | |
| 'identifier' => 'Formulário de contato', | |
| 'email' => $from, | |
| 'name' => $name, | |
| 'message' => $message, | |
| 'phone' => $phone, | |
| )); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment