How to update URL links of images

If the URL address of your installation of Post Affiliate Pro has changed (e.g. the installation has been moved to another domain or directory) and if you are using full URLs in your banner images, campaign logos, application logo, you can update these links by this script:
include 'PapApi.class.php';

$session = new Pap_Api_Session('url_to_your_pap_installation/scripts/server.php');

if(!@$session->login('merchant_username', 'merchant_password')) {
  die("Cannot login. Message: ". $session->getMessage());

$urlSearchOldPart = 'https://my_old_PAP_url/';
$urlReplaceNewPart = 'https://my_new_PAP_url/';

$request = new Gpf_Rpc_ActionRequest('Pap_Common_Utils_LinksUpdater', 'updateImagesUrlLinks', $session);

$request->addParam('oldUrlPart', $urlSearchOldPart);
$request->addParam('newUlrPart', $urlReplaceNewPart);

try  {
} catch(Exception $e){
  die("API call error: " . $e->getMessage());

$answer = $request->getResponseObject()->toObject();
if ($answer->success != GPf::YES) {
  echo 'Error occured: ' . $answer->errorMessage;

echo $answer->infoMessage;