Changeset 3416398
- Timestamp:
- 12/10/2025 12:33:56 PM (2 months ago)
- Location:
- apimo/trunk
- Files:
-
- 3 edited
-
apimo.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
-
templates/single_property_style_2.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
apimo/trunk/apimo.php
r3235381 r3416398 7 7 * Description: Manage Real Estat Bussiness 8 8 9 * Version: 2.6. 3.19 * Version: 2.6.4 10 10 11 11 * Author: ApiWork -
apimo/trunk/readme.txt
r3274825 r3416398 3 3 Tags: real estate, property management, listings, clients, leads, showings, open houses, reports 4 4 Tested up to: 6.7.1 5 Stable tag: 2.6. 3.15 Stable tag: 2.6.4 6 6 License: GPLv2 7 7 License URI: https://www.gnu.org/licenses/gpl-2.0.html 8 8 9 == Description == 10 Are you a real estate agent or broker looking to streamline your daily operations? 11 12 Discover Apimo connector — a powerful, user-friendly WordPress plugin designed to help you: 13 – Effortlessly list and manage properties for sale or rent 14 – Organize and track showings and open houses with ease 15 16 This plugin integrates smoothly with your existing WordPress site and is built with simplicity and efficiency in mind. 17 18 Please note: Apimo Connector is not an official Apimo plugin and is not developed by Apimo. 19 20 Start simplifying your real estate workflow today with Manage Real Estate Business! 9 Are you a real estate agent or broker looking for a way to streamline your business operations? Look no further! Our plugin is here to help. 10 11 With Manage Real Estate Business, you can easily: 12 13 - List and manage properties for sale or rent 14 - Schedule and manage showings and open houses 15 16 Our plugin integrates seamlessly with your WordPress website and is user-friendly and intuitive. Start streamlining your real estate business today with Manage Real Estate Business! 21 17 22 18 == Installation == … … 149 145 The plugin is specifically designed to work with the Apimo API. Importing properties from a different platform would require custom development to integrate the other platform's API with the plugin. 150 146 147 = How can I contact support if I have issues with the plugin? = 148 149 For support with the plugin, you can contact the Apimo support team through their official website or email. Ensure you have your token and provider ID ready for quicker assistance. 150 151 151 = How do I update the plugin to the latest version? = 152 152 … … 174 174 175 175 == Changelog == 176 177 = 2.6.4 = 178 *fix: dynamically send leads to correct Apimo agency 179 *Previous implementation always sent leads to a hardcoded agency. 180 *Now detects the agency based on property reference (if available). 181 *Falls back to the first saved agency if no property reference is present. 182 *Ensures leads from product pages go to the correct agency in Apimo. 183 *Improves API integration and prevents misrouted leads. 176 184 177 185 = 2.6.3 = -
apimo/trunk/templates/single_property_style_2.php
r3235354 r3416398 1828 1828 1829 1829 $apimo_api_keys = get_option('apimo_key_data'); 1830 1830 1831 1831 $company_id = trim($apimo_api_keys[0]['company_id']); 1832 1832 $key = trim($apimo_api_keys[0]['key']); 1833 $credentials = base64_encode($company_id . ':' . $key); // Add the colon separator here1833 $credentials = base64_encode($company_id . ':' . $key); // Add the colon separator 1834 1834 1835 1836 1835 if ($_SERVER['REQUEST_METHOD'] === 'POST') { 1837 // Configuration Apimo 1836 1837 /** 1838 * ------------------------------------ 1839 * HOTFIX: Detect the correct agency 1840 * ------------------------------------ 1841 */ 1842 $dynamic_agency_id = null; 1843 1844 // CASE 1: Lead sent from a property page (contains property reference) 1845 if (!empty($_POST['reference'])) { 1846 1847 $property_ref = sanitize_text_field($_POST['reference']); 1848 1849 // Fetch the property to get its agency ID 1850 $ch_property = curl_init("https://api.apimo.pro/properties/{$property_ref}"); 1851 curl_setopt_array($ch_property, [ 1852 CURLOPT_RETURNTRANSFER => true, 1853 CURLOPT_HTTPHEADER => [ 1854 'Authorization: Basic ' . $credentials, 1855 'Content-Type: application/json' 1856 ] 1857 ]); 1858 1859 $property_response = curl_exec($ch_property); 1860 curl_close($ch_property); 1861 1862 $property_json = json_decode($property_response, true); 1863 1864 // If the property has an agency → use it 1865 if (!empty($property_json['agency']['id'])) { 1866 $dynamic_agency_id = $property_json['agency']['id']; 1867 } 1868 } 1869 1870 // CASE 2: No property reference → use first agency saved 1871 if (!$dynamic_agency_id) { 1872 $dynamic_agency_id = $apimo_api_keys[0]['agency_id']; 1873 } 1874 1875 // Build correct API config 1838 1876 $apimoConfig = [ 1839 1877 'apiUrl' => 'https://api.apimo.pro/agencies', 1840 'agencyId' => '23531 ',1878 'agencyId' => $dynamic_agency_id, 1841 1879 'credentials' => $credentials 1842 1880 ]; 1843 1881 1844 // Validate form 1882 /** 1883 * ------------------------------------ 1884 * Validate form 1885 * ------------------------------------ 1886 */ 1845 1887 $errors = []; 1846 1888 1847 1889 if (empty($_POST['lastName'])) { 1848 1890 $errors[] = 'Le nom est requis'; 1849 1891 } 1850 1892 1851 1893 if (empty($_POST['email']) && empty($_POST['phone'])) { 1852 1894 $errors[] = 'Email ou téléphone est requis'; … … 1861 1903 } 1862 1904 1863 // If no errors, process form 1905 /** 1906 * ------------------------------------ 1907 * Submit to Apimo API 1908 * ------------------------------------ 1909 */ 1864 1910 if (empty($errors)) { 1865 // Prepare data for API 1911 1912 // Prepare data 1866 1913 $leadData = [ 1867 1914 'reference' => uniqid('WP-'), … … 1873 1920 'currency' => 'EUR', 1874 1921 'referral' => '1', 1875 1876 // Form data1922 1923 // Form fields 1877 1924 'lastname' => strip_tags($_POST['lastName']), 1878 1925 'firstname' => strip_tags($_POST['firstName'] ?? ''), … … 1883 1930 ]; 1884 1931 1885 // Initialize cURL1932 // Send lead 1886 1933 $ch = curl_init(rtrim($apimoConfig['apiUrl'], '/') . '/' . trim($apimoConfig['agencyId']) . '/leads'); 1887 1934 1888 1935 curl_setopt_array($ch, [ 1889 1936 CURLOPT_POST => true, … … 1895 1942 CURLOPT_POSTFIELDS => json_encode($leadData) 1896 1943 ]); 1897 1944 1898 1945 $response = curl_exec($ch); 1899 1946 $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 1900 1947 1901 1948 if (curl_errno($ch)) { 1902 echo '<div class="apimo_error"> Erreur de connexion à l\'API: ' . curl_error($ch) . '</div>';1949 echo '<div class="apimo_error">API connection error: ' . curl_error($ch) . '</div>'; 1903 1950 } elseif ($httpCode !== 200) { 1904 echo '<div class="apimo_error"> Erreur API Apimo: ' . $response . '</div>';1951 echo '<div class="apimo_error">Apimo API error: ' . $response . '</div>'; 1905 1952 } 1906 1953 1907 1954 curl_close($ch); 1955 1908 1956 } else { 1909 // Display errors 1957 1910 1958 echo '<div class="apimo_error">'; 1911 1959 foreach ($errors as $error) { … … 1913 1961 } 1914 1962 echo '</div>'; 1963 1915 1964 } 1916 1965 } 1966 1917 1967 ?> 1918 1968
Note: See TracChangeset
for help on using the changeset viewer.