Retrieve cross-sell campaign by code
Last updated: 28-Nov-2022
Rate this article:
Overview
Use the getCrossSellCampaign method to extract information about the cross-sell campaign identified by the provided campaign code.
Request parameters
Parameters | Type | Required/Optional | Description |
---|---|---|---|
sessionID |
String | Required |
Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect. The sessionID expires in 10 minutes. |
CampaignCode |
String | Required | The campaign code. |
Request sample
<?php
declare(strict_types=1);
// Start clear CLI
echo chr(27).chr(91).'H'.chr(27).chr(91).'J';
// End clear CLI
$executionStartTime = microtime(true);
$apiVersion = '6.0';
$apiHost = "http://api.avangate.local";
$host = $apiHost."/soap/" . $apiVersion . "/";
$client = new SoapClient(
$host."?wsdl",
[
'location' => $host,
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE
]
);
$client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');
// Please be aware to consider valid data
$merchantCode = 'your_merchant_code';
$key = 'your_merchant_key';
// Generate hash for login
$date = gmdate('Y-m-d H:i:s');
$string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
$hash = hash_hmac('md5', $string, $key);
try {
$sessionID = $client->login($merchantCode, $date, $hash);
} catch (SoapFault $e) {
echo $e->getMessage();
}
var_dump("Generated sessionID: ". $sessionID);
echo "\n\r";
$crossSellCampaignCode = '2Xrl83J0k+qOr3W1ceTwZnHHr30=';
try {
$result = $client->getCrossSellCampaign($sessionID, $crossSellCampaignCode);
echo "\n\rGET CROSS SELL CAMPAIGNS: \n\r";
print_r(json_encode($result, JSON_PRETTY_PRINT));
} catch (SoapFault $e) {
echo $e->getMessage();
}
$executionEndTime = microtime(true);
// The duration will be displayed in seconds and milliseconds.
$seconds = round($executionEndTime - $executionStartTime, 2);
// Print it out
echo "\n\rThis script took $seconds to execute.\n\r";
Response
Parameters | Type/Description |
---|---|
CrossSellCampaign |
Object |
Related articles
Rate this article: