I have a use case where I need to shorten my Url and send it in a SMS.I have an HTML page which on calling, updates my customer's details. It basically updates an attribute of an object in Sales Cloud for that particular lead. When user clicks on that link that we have given in the SMS, the HTML page opens and the information for that user is verified(The attribute which was earlier set to unverified is now set to verified).
Problem In my case, the bitly link that gets generated, itself gets hit(probably when it is sent to bitly server to shorten the link) and information for the user gets verified even if the user doesn't click on that link.
This is my code:
%%[
var @leadId, @shortenUrl, @bitlyUrl, @link
Set @contacts = RetrieveSalesforceObjects("Lead", "Id,FirstName,LastName", "Combined_Mobile__c", "=",
6569698800)
if rowcount(@contacts) != 0 then
Set @row = Row(@contacts, 1)
Set @firstName = FIELD(@row, "FirstName")
Set @lastName = FIELD(@row, "LastName")
Set @leadId = FIELD(@row, "Id")
endif
Set @encodedId = Base64Encode(@leadId)
set @urlLink =Concat('<url>','?leadID=',@encodedId)
set @bitlyUrl = 'https://api-ssl.bitly.com/v3/shorten?access_token=xxxxxx&format=txt&longUrl='
set @verifyUrl = Concat(@bitlyUrl,@urlLink,"&format=txt")
]%%
The HTML page has this piece of code:
%%[
set @encodedId = RequestParameter("leadID")
set @leadId = Base64Decode(@encodedId,'UTF-8', 1)
set @contacts= RetrieveSalesforceObjects("Lead", "Lead_Type__c,FirstName", "Id", "=",@leadId)
if rowcount(@contacts) != 0 then
Set @row = Row(@contacts, 1)
Set @firstName = FIELD(@row, "FirstName")
set @result = UpdateSingleSalesforceObject("Lead",@leadId,"Contact_Verified__c","Verified")
endif
]%%
<!DOCTYPE html>
<html>
<!--HTML header and body code-->
</html>
Any suggestions?