title: Store Data to ZOHO CRM using LARAVEL and ZOHO CRM API
body: <p>This is how to save data to zoho crm api using laravel, the process of this is the data will be check before uploading to crm to avoid duplicate data on zoho crm.
  public function importToZoho(){</p>
  
  <pre><code>         $publicUser = User::withRole('User')-&gt;get();
           $count = 1;
           $auth="YOUR TOKEN ID";
  
           //Insert Records to CRM     
           $xml =   '&lt;?xml version="1.0" encoding="UTF-8"?&gt;';
           $xml .=  '&lt;Leads&gt;'; 
           foreach($publicUser as $user){
  
  
                  if(SohoUploaded::where('user_id', $user-&gt;id)-&gt;exists()){
                      echo "File Exists";
                  }else{
  
                  $uploadedZoho = new SohoUploaded();
                  $uploadedZoho-&gt;user_id = $user-&gt;id;
                  $uploadedZoho-&gt;email = $user-&gt;email;
                  $uploadedZoho-&gt;first_name = $user-&gt;first_name;
                  $uploadedZoho-&gt;last_name = $user-&gt;last_name;
                  $uploadedZoho-&gt;save();
  
  
                 $xml .= '&lt;row no="'.$count++.'"&gt;';
  
                  $xml .= '&lt;FL val="Lead Owner"&gt;Sales Shift&lt;/FL&gt;';
                  $xml .= '&lt;FL val="Company"&gt;'.$user-&gt;company.'&lt;/FL&gt;';
                  $xml .= '&lt;FL val="First Name"&gt;'. $user-&gt;first_name.'&lt;/FL&gt;';
                  $xml .= '&lt;FL val="Last Name"&gt;'. $user-&gt;last_name.'&lt;/FL&gt;';
                  $xml .= '&lt;FL val="Email"&gt;'. $user-&gt;email.'&lt;/FL&gt;';
                  $xml .= '&lt;FL val="Phone"&gt;'. $user-&gt;phone.'&lt;/FL&gt;';
  
                  $xml .= '&lt;/row&gt;';
  
       }
  
               }      
              $xml .= '&lt;/Leads&gt;';                       
              $url ="https://crm.zoho.com/crm/private/xml/Leads/insertRecords?duplicateCheck=1&amp;";
              $query="authtoken=".$auth."&amp;scope=crmapi&amp;xmlData=".$xml;
              $ch = curl_init();
              /* set url to send post request */
              curl_setopt($ch, CURLOPT_URL, $url);
              /* allow redirects */
              curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
              /* return a response into a variable */
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
              /* times out after 30s */
              curl_setopt($ch, CURLOPT_TIMEOUT, 30);
              /* set POST method */
              curl_setopt($ch, CURLOPT_POST, 1);
              /* add POST fields parameters */
              curl_setopt($ch, CURLOPT_POSTFIELDS, $query);// Set the request as a POST FIELD for curl.
  
              //Execute cUrl session
              $response = curl_exec($ch);
              curl_close($ch);
  
  
  
  
           return redirect()-&gt;to('/public-user')-&gt;withSuccess('New leads uploaded to Zoho CRM');
  
  }   
  </code></pre>
  
  <p>Let me know if you have some question regarding this post, im happy to help.</p>