Gigya Job Openings

accounts.importProfilePhoto JS

Skip to end of metadata
Go to start of metadata

Description

This method imports a user's profile photo to Gigya's server. 
By default the imported photo is treated as a temporary photo. You can decide whether to publish the photo into the user's account, using the publish parameter (see below), or you can publish later using the accounts.publishProfilePhoto API method.
The supported photo file types are: image/gif, image/png, image/jpeg.

Note: If you plan on integrating Gigya's Accounts API, we highly recommend reading the Registration-as-a-Service Guide. Registration-as-a-Service (RaaS) is a premium platform that requires separate activation. If RaaS is not part of your site package, please contact Gigya by filling in a support form through the Console. You can access the support page by clicking Support on the upper menu after logging into the Gigya Console.

Note: This method is also supported in our REST API. If you wish to execute this method from your server, please refer to

REST API > accounts.importProfilePhoto

Syntax

 

Parameters

The following table lists the available parameters:

RequiredNameTypeDescription
urlstringThe URL of the photo to import. 
regTokenstringThe regToken returned from accounts.initRegistrationaccounts.register or accounts.login API calls when the registration process has not been finalized. Please note that the regToken you receive from Gigya is valid for only one hour.
publishBooleanIndicates whether to publish this photo to the user's profile or treat it as a temporary photo. The default value is 'false', i.e. the photo is temporary. You can later publish a temporary photo using the accounts.publishProfilePhoto API method. If published, the photo is saved in the photoURL field of the user's Profile, in addition the photo is trimmed to the size defined in the site's Policies (64X64 by default) and saved in the thumbnailURL field.
callbackfunctionA reference to a callback function. Gigya calls the specified function along with the results of the API method when the API method completes.
The callback function should be defined with the following signature: functionName(response).

Code Sample

<script type="text/javascript">
    function showPhotoInfo(response) {
        alert(JSON.stringify(response));
    }
    function doImportPhoto() {
        var photoParams = {
            URL: 'http://<MY_SERVER>.com/path/to/photo.jpg',
            callback: showPhotoInfo,
            publish: false
        };

        gigya.accounts.importProfilePhoto(photoParams);
    }
</script>

Notes:

  • This sample is not meant to be fully functional code. For brevity's sake, only the code required for demonstrating the API call itself is presented.
  • To run the code on your own domain, add your Gigya API key to the gigya.js URL. A Gigya API key can be obtained on the Site Dashboard page on Gigya's website. Please make sure that the domain from which you are loading the page is the same domain name that you used for generating the API key.
  • In some cases it is necessary to connect/login the user to a provider ? prior to calling the API method. You can learn more in the Social Login guide.