doppelme logo

Example Integration Code

Below are 4 example ASP files that illustrate how to integrate DoppelMe avatars within your website using the SOAP API. These are given for example only and no warranty is provided. These example are given in ASP - but the same prinicples can be applied to code in other languages/frameworks.

doppelme.asp | profile_avatar.asp | profile_avatar_create.asp | profile_avatar_updated.asp

Example page showing how to embed the avatar editor within your site

The main page which allows your users to edit their avatars
<!-- #include virtual="/include/doppelme.asp"-->
<html>
<head>
</head>
<body>
<%
    
    '//these values have been read from your database on login
    USER_ID         = Session("UserID")         '//your user's id
    DOPPELME_KEY    = Session("DoppelMeKey")    '//your user's doppelme avatar key    
   
    if len(DOPPELME_KEY) = 0 then
        '//user doesnt have an avatar - ask if they want to create one...
        Response.Redirect "/profile_avatar_create.asp"
    end if
    
    '//retrieve the ValidationKey details for  this user's avatar (we need this to be able to edit their avatar)
    sURL    = "GetDetailsFromPartnerUserID"    
    sDATA    = "partner_id=" & DM_PARTNER_ID & "&partner_key=" & DM_PARTNER_KEY & "&partner_user_id=" & USER_ID & "&is_test=false"        
    sReturnXML = PartnerServiceCall(sURL, sDATA)
                        
    if len(sReturnXML) = 0 then
        '//no avatar found for these details - have you supplied the correct keys?        
        Response.End
    end if
    
    set xmlDoc = CreateObject("MSXML.DOMDocument")
    xmlDoc.async = false
    xmlDoc.LoadXML(sReturnXML)
    set xmlRoot = xmlDoc.documentElement
        
    sVALIDATION_KEY    = xmlRoot.selectSingleNode("ValidationKey").Text
                
%>
    
    <div style="height: 450px;margin: 0 auto;">        
    <iframe src="<%=DOPPELME_SITE%>/partner/partner_validate.asp?stripped=yes&pid=<%=DM_PARTNER_ID%>&puid=<%=USER_ID%>&validkey=<%=sVALIDATION_KEY%>&doppelmekey=<%=sDOPPELME_KEY%>&callback=<%=Server.UrlEncode("http://mysite.com/profile_avatar_updated.asp")%>" 
    style="position:absolute;overflow:hidden;width:660px;height:450px;border: 0;border-collapse: collapse;margin: 0 auto;" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" vspace="5" hspace = "0"></iframe>
    </div>                
    
</body>
</html>