PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label salesforce. Show all posts
Showing posts with label salesforce. Show all posts

Thursday, November 10, 2022

[FIXED] How to Implement and Check DKIM in Salesfroce

 November 10, 2022     dkim, salesforce, salesforce-service-cloud     No comments   

Issue

Could you guys explain to me that how to implement and check DKIM in Salesforce with example

Thanks in Advance, Vingesh.B


Solution

In order to do this, you have to be a System Administrator in Salesforce and have the ability to modify your DNS records with your domain registrar. The process involves creating a unique key in Salesforce, then create the DNS record that uses the key.

Create a DKIM Key in Salesforce Classic



Answered By - Matt Kaufman
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Saturday, August 6, 2022

[FIXED] How can i get a Refresh token using the Salesforce OAuth?

 August 06, 2022     oauth, salesforce     No comments   

Issue

When i first authenticate with OAuth to Salesforce i dont get back a refresh token , i just get back an access token. So if the token needs to be refreshed by using the following:

var client = new RestClient("https://myOrg.salesforce.com/services/oauth2/token");
var request = new RestRequest("", Method.POST);
request.AddParameter("refresh_token", {currentRefreshToken}, ParameterType.GetOrPost);
request.AddParameter("grant_type", "refresh_token", ParameterType.GetOrPost);
request.AddParameter("client_id", {clientId}, ParameterType.GetOrPost);
request.AddParameter("client_secret", {clientsecret}, ParameterType.GetOrPost);
var response = client.Execute(request);

The currentRefreshToken is NULL because i didnt receive any refresh token on the initial authentication response. The initial call to authenticate is

    https://login.salesforce.com/services/oauth2/authorize? client_id={consumer_key}& 
    redirect_uri={callback_url}& response_type=code

and this doesnt give back a refreshtoken. How can i get an initial refresh token ?


Solution

The connected app has to allow issuing refresh tokens (check if "scopes" contains refresh and if there isn't something like "immediately expire refresh tokens" set).

And then you need to ask for it, add optional scope=refresh_token parameter to your request.

https://help.salesforce.com/s/articleView?id=sf.remoteaccess_oauth_user_agent_flow.htm&type=5



Answered By - eyescream
Answer Checked By - Clifford M. (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, April 21, 2022

[FIXED] How to Connect Salesforce using R?

 April 21, 2022     api, connection, r, salesforce     No comments   

Issue

I am getting 500 status. Can you anyone help me on this please

I am trying to connect Salesforce using R when i try perform the login operation. I am not successful, can you please look into this code and correct me where i am missing.

library(RCurl)
library(httr)

  body1 = '<?xml version="1.0" encoding="utf-8"?>
  <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body>
  <login xmlns="urn:partner.soap.sforce.com">
  <username>xxxxxx.Test@xxxxxx.com.xxxxxxx</username>
  <password>xxxxxxxxxxxx</password>
  </login>
  </s:Body>
  </s:Envelope>'

x <- httr::POST(url = "https://test.salesforce.com/services/Soap/48.0", body = body1, content_type("text/xml;charset=UTF-8"),SOAPAction = "login")
x$status_code

Solution

Thanks for answering the questions. After several tries, I understood there was some issue in the headers. I fixed the headers and its now working great. I am able to perform a query in Salesforce without any issues. I have posted my complete code here so anyone can make use for it. I am not an expert in this but still managed with this code.

#######Required Packages
library(RCurl)
library(httr)
library(XML)
library(jsonlite)
library(xml2)
library(magrittr)
library(randomNames)
library(rlang)
library(generator)
library(stringr)
require(data.table)

body1 = '<?xml version="1.0" encoding="utf-8"?>\
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">\
  <s:Body>\
    <login xmlns="urn:partner.soap.sforce.com">\
      <username>XXXXXXXXXXXXXX</username>\
      <password>XXXXXXXXXXXXXXX</password>\
    </login>\
  </s:Body>\
</s:Envelope>\n'

require(httr)
################################Posting the Login##############################################
result <- POST("https://test.salesforce.com/services/Soap/u/48.0",body = body1,add_headers(.headers = c("Content-Type"="text/xml",'SOAPAction' = "https://test.salesforce.com")))

##############Parsing XML###############################################################
Output <- content(result)
doc = xmlTreeParse(Output, useInternal = TRUE)
top = xmlRoot(doc) 
xmlName(top)
names(top) 
names(top[[1]] [[1]] [[1]])
Session = top[[ 1 ]] [[1]] [[1]] [["sessionId"]] 
SessionId <- Session [1][1]$text
tok <- xmlToList(SessionId)  
Se <- paste("Bearer",tok,Sep="")
Se = trimws(Se)
Sever = top[[ 1 ]] [[1]] [[1]] [["serverUrl"]] 
SessionURL <- Sever [1][1]$text

################SF Query###########################################
SFQuery <- "SELECT Id,FirstName FROM Conatct limit 10"
SFQuery_Req <- GET(Pam,query = list(q=SFQuery),add_headers(Authorization=Se))
SFQuery_Con <- content(SFQuery_Req, as = 'text') %>% fromJSON()
SFQuery_Con_DF <- data.frame(SFQuery_Con$records)


Answered By - vijayaraghavan Devaraj
Answer Checked By - Katrina (PHPFixing Volunteer)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing