• raj singh 26
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
Hi All,

Greetings!

We have integrated Salesforce with ServiceNow using REST APIs, where we created a dedicated integration user.
Now we need to integrate Salesforce with HR Connect, so can I use creds of same integration user or go with a new integration user?

Appreciate your help in this regards,

Thanks!
Hi,

I am able to integrate Salesforce and PHP using PHP toolkit provided Salesforce.  Our PHP team is able to push data from PHP into Salesforce successfully.  Just wanted to know how to sync data between PHP and Salesforce using PHP toolkit, i.e., if some changes are made in the records at Salesforce end, then same should be reflected at PHP end also.

Thanks!
public class Send_Data_To_NFS2{ 
    public string result;             
    public HttpResponse res;   
    
    public string reqResMethod(string strJSON, string strEndPoint){
        Http h = new Http();
        HttpRequest req = new HttpRequest();  
        req.setHeader('Content-Type','application/json');        
        string strJSONBody = strJSON;        
        req.setBody(strJSONBody);
        req.setMethod('POST');
        req.setEndpoint(strEndPoint);
        res = h.send(req);
        result = res.getBody();          
        result = result.replace('\\', '').removeStart('"').removeEnd('"'); 
        system.debug('*****res****'+res);         
        system.debug('*****res.getbody****'+result);                
        return result;
    }
        
    Public void push_Data(){            
  
        string strJSON = '-------------------------------------------------------------';
  
        string strEndPoint = '---------------------------------------------------------';
        string resp = reqResMethod(strJSON, strEndPoint);
        
  
        NFSWrapper deserializedResponse = (NFSWrapper)JSON.deserialize(resp, NFSWrapper.class);                  
  
        
        secondResponse deserializedResponse1;
        if(deserializedResponse != null && deserializedResponse.StatusCode == '200'){  
  
  
            string strJSON1 = '------------------------------------------------------------------------';  
            string strEndPoint1 = '-------------------------------------------';

            string resp1 = reqResMethod(strJSON1, strEndPoint1);
            
            deserializedResponse1 = (secondResponse)JSON.deserialize(resp1, secondResponse.class);
            
            
            if(deserializedResponse1 != null && deserializedResponse1.StatusCode == '200'){
            
            Attachment att = new Attachment();
            att = [select name, body from Attachment where ParentId = '*********************'];
            string fileBody = EncodingUtil.base64Encode(att.Body);
            system.debug('**************file body**************' + fileBody);                       
            string url = '----------------------------------------------------------------------';
            url = url + deserializedResponse1.OpportunityId;
            url = url + '&filename=test.pdf';       
            string resp2 = reqResMethod(filebody, url);
            
            //3rd POST Deserilaization
            thirdResponse deserializedResponse2 = (thirdResponse)JSON.deserialize(resp2, thirdResponse.class);
            if(deserializedResponse2 != null && deserializedResponse2.StatusCode == '200'){
                system.debug('*****ATTACHMENT ADDED SUCCESSFULLY****');
            }
            
            else{
                system.debug('*****ERROR MESSAGE****' + deserializedResponse2.Message);
            }
            
        }else{
            system.debug('*****BAD REQUEST2****');
            system.debug('*****MESSAGE****'+ deserializedResponse.Message);
        }
        
                   
            
        }else{            
            system.debug('*****BAD REQUEST1****');
            system.debug('*****MESSAGE****'+ deserializedResponse1.Message);
        }
        
    }       
    
    //Wrapper Classes
    
    public class Nttrapper{
        public String StatusCode;
        public String OpportunityId;
        public String Message;
        public string[] ContactIds;        
        public String BrokerId;
        public cls_Addresses[] Addresses;
        public String AccountId;
    }        

   public class cls_Addresses {
        public String type;
        public String Id;  
    }
    
    public class secondResponse{
        public String StatusCode;
        public String OpportunityId;
        public String Message;
        public String BSNumber;
    }
    
    public class thirdResponse{
        public String StatusCode;
        public String Message;
      
    }   
}
public class Send_Data_To_NFS2{ 
    public string result;             
    public HttpResponse res;   
    
    public string reqResMethod(string strJSON, string strEndPoint){
        Http h = new Http();
        HttpRequest req = new HttpRequest();  
        req.setHeader('Content-Type','application/json');        
        string strJSONBody = strJSON;        
        req.setBody(strJSONBody);
        req.setMethod('POST');
        req.setEndpoint(strEndPoint);
        res = h.send(req);
        result = res.getBody();          
        result = result.replace('\\', '').removeStart('"').removeEnd('"'); 
        system.debug('*****res****'+res);         
        system.debug('*****res.getbody****'+result);                
        return result;
    }
        
    Public void push_Data(){            
  
        string strJSON = '-------------------------------------------------------------';
  
        string strEndPoint = '---------------------------------------------------------';
        string resp = reqResMethod(strJSON, strEndPoint);
        
  
        NFSWrapper deserializedResponse = (NFSWrapper)JSON.deserialize(resp, NFSWrapper.class);                  
  
        
        secondResponse deserializedResponse1;
        if(deserializedResponse != null && deserializedResponse.StatusCode == '200'){  
  
  
            string strJSON1 = '------------------------------------------------------------------------';  
            string strEndPoint1 = '-------------------------------------------';

            string resp1 = reqResMethod(strJSON1, strEndPoint1);
            
            deserializedResponse1 = (secondResponse)JSON.deserialize(resp1, secondResponse.class);
            
            
            if(deserializedResponse1 != null && deserializedResponse1.StatusCode == '200'){
            
            Attachment att = new Attachment();
            att = [select name, body from Attachment where ParentId = '*********************'];
            string fileBody = EncodingUtil.base64Encode(att.Body);
            system.debug('**************file body**************' + fileBody);                       
            string url = '----------------------------------------------------------------------';
            url = url + deserializedResponse1.OpportunityId;
            url = url + '&filename=test.pdf';       
            string resp2 = reqResMethod(filebody, url);
            
            //3rd POST Deserilaization
            thirdResponse deserializedResponse2 = (thirdResponse)JSON.deserialize(resp2, thirdResponse.class);
            if(deserializedResponse2 != null && deserializedResponse2.StatusCode == '200'){
                system.debug('*****ATTACHMENT ADDED SUCCESSFULLY****');
            }
            
            else{
                system.debug('*****ERROR MESSAGE****' + deserializedResponse2.Message);
            }
            
        }else{
            system.debug('*****BAD REQUEST2****');
            system.debug('*****MESSAGE****'+ deserializedResponse.Message);
        }
        
                   
            
        }else{            
            system.debug('*****BAD REQUEST1****');
            system.debug('*****MESSAGE****'+ deserializedResponse1.Message);
        }
        
    }       
    
    //Wrapper Classes
    
    public class Nttrapper{
        public String StatusCode;
        public String OpportunityId;
        public String Message;
        public string[] ContactIds;        
        public String BrokerId;
        public cls_Addresses[] Addresses;
        public String AccountId;
    }        

   public class cls_Addresses {
        public String type;
        public String Id;  
    }
    
    public class secondResponse{
        public String StatusCode;
        public String OpportunityId;
        public String Message;
        public String BSNumber;
    }
    
    public class thirdResponse{
        public String StatusCode;
        public String Message;
      
    }   
}
public class Send_Data_To_NFS2{ 
    public string result;             
    public HttpResponse res;   
    
    public string reqResMethod(string strJSON, string strEndPoint){
        Http h = new Http();
        HttpRequest req = new HttpRequest();  
        req.setHeader('Content-Type','application/json');        
        string strJSONBody = strJSON;        
        req.setBody(strJSONBody);
        req.setMethod('POST');
        req.setEndpoint(strEndPoint);
        res = h.send(req);
        result = res.getBody();          
        result = result.replace('\\', '').removeStart('"').removeEnd('"'); 
        system.debug('*****res****'+res);         
        system.debug('*****res.getbody****'+result);                
        return result;
    }
        
    Public void push_Data(){            
  
        string strJSON = '-------------------------------------------------------------';
  
        string strEndPoint = '---------------------------------------------------------';
        string resp = reqResMethod(strJSON, strEndPoint);
        
  
        NFSWrapper deserializedResponse = (NFSWrapper)JSON.deserialize(resp, NFSWrapper.class);                  
  
        
        secondResponse deserializedResponse1;
        if(deserializedResponse != null && deserializedResponse.StatusCode == '200'){  
  
  
            string strJSON1 = '------------------------------------------------------------------------';  
            string strEndPoint1 = '-------------------------------------------';

            string resp1 = reqResMethod(strJSON1, strEndPoint1);
            
            deserializedResponse1 = (secondResponse)JSON.deserialize(resp1, secondResponse.class);
            
            
            if(deserializedResponse1 != null && deserializedResponse1.StatusCode == '200'){
            
            Attachment att = new Attachment();
            att = [select name, body from Attachment where ParentId = '*********************'];
            string fileBody = EncodingUtil.base64Encode(att.Body);
            system.debug('**************file body**************' + fileBody);                       
            string url = '----------------------------------------------------------------------';
            url = url + deserializedResponse1.OpportunityId;
            url = url + '&filename=test.pdf';       
            string resp2 = reqResMethod(filebody, url);
            
            //3rd POST Deserilaization
            thirdResponse deserializedResponse2 = (thirdResponse)JSON.deserialize(resp2, thirdResponse.class);
            if(deserializedResponse2 != null && deserializedResponse2.StatusCode == '200'){
                system.debug('*****ATTACHMENT ADDED SUCCESSFULLY****');
            }
            
            else{
                system.debug('*****ERROR MESSAGE****' + deserializedResponse2.Message);
            }
            
        }else{
            system.debug('*****BAD REQUEST2****');
            system.debug('*****MESSAGE****'+ deserializedResponse.Message);
        }
        
                   
            
        }else{            
            system.debug('*****BAD REQUEST1****');
            system.debug('*****MESSAGE****'+ deserializedResponse1.Message);
        }
        
    }       
    
    //Wrapper Classes
    
    public class Nttrapper{
        public String StatusCode;
        public String OpportunityId;
        public String Message;
        public string[] ContactIds;        
        public String BrokerId;
        public cls_Addresses[] Addresses;
        public String AccountId;
    }        

   public class cls_Addresses {
        public String type;
        public String Id;  
    }
    
    public class secondResponse{
        public String StatusCode;
        public String OpportunityId;
        public String Message;
        public String BSNumber;
    }
    
    public class thirdResponse{
        public String StatusCode;
        public String Message;
      
    }   
}

I want to  link salesforce account with online forms to update account information in real time.

 

For This I want to,

 

Develop PHP component capable of communicating with Salesforce and pulling down address data.

 

Develop a WordPress plugin that can be easily configured with salesforce login information, a schedule of when a sync should automatically happen, and a button to "manually sync."

 

 Please Can Anyone help on this?