JezK
Edit File: zoho-verify-lead.php
<?php error_reporting(E_ALL); ini_set('display_errors', 1); if (!session_id() && !headers_sent()) { ini_set('session.cookie_httponly', 1); if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') { ini_set('session.cookie_secure', 1); } ini_set('session.use_only_cookies', 1); ini_set('session.cookie_samesite', 'Strict'); session_start(); } require_once('/home/authentica.com/public_html/wp-content/plugins/zoho-crm-api/zoho-auth.php'); if (!defined('ABSPATH')) { exit; } $body = file_get_contents('php://input'); $data = json_decode($body, true); // CSRF if (!isset($data['csrf_token']) || !isset($_SESSION['csrf_token']) || $data['csrf_token'] !== $_SESSION['csrf_token']) { header('Content-Type: application/json'); header('X-Content-Type-Options: nosniff'); http_response_code(403); echo json_encode(['error' => 'Invalid or missing CSRF token']); exit; } // lead id required if (empty($data['lead_id'])) { header('Content-Type: application/json'); header('X-Content-Type-Options: nosniff'); echo json_encode(['error' => 'Missing lead_id']); exit; } $auth_response = get_zoho_access_token(); if (!isset($auth_response['response']['access_token'])) { header('Content-Type: application/json'); header('X-Content-Type-Options: nosniff'); echo json_encode(['error' => 'Failed to fetch access token']); exit; } $access_token = $auth_response['response']['access_token']; $url = "https://www.zohoapis.com/crm/v2/Leads/" . urlencode($data['lead_id']); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Authorization: Bearer $access_token", "Content-Type: application/json" ]); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); $response = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); // 200 => exists $exists = ($code === 200); header('Content-Type: application/json'); header('X-Content-Type-Options: nosniff'); echo json_encode(['exists' => $exists, 'http_code' => $code]); exit;