function shrinktheweb_generateRequestArgs in ShrinkTheWeb 8
Same name and namespace in other branches
- 6 shrinktheweb.api.inc \shrinktheweb_generateRequestArgs()
- 7 shrinktheweb.api.inc \shrinktheweb_generateRequestArgs()
Generate the request arguments.
Parameters
$aOptions:
Return value
mixed
2 calls to shrinktheweb_generateRequestArgs()
- shrinktheweb_deleteThumbnail in ./
shrinktheweb.api.inc - Delete thumbnail.
- shrinktheweb_getThumbnail in ./
shrinktheweb.api.inc - Gets the thumbnail for the specified website, stores it in the cache, and then returns the relative path to the cached image.
File
- ./
shrinktheweb.api.inc, line 212
Code
function shrinktheweb_generateRequestArgs($aOptions) {
$aArgs['stwaccesskeyid'] = ACCESS_KEY;
$aArgs['stwu'] = SECRET_KEY;
$aArgs['stwver'] = VER;
// If SizeCustom is specified and widescreen capturing is not activated,
// then use that size rather than the size stored in the settings.
if (!$aOptions['FullSizeCapture'] && !$aOptions['WidescreenY']) {
// Do we have a custom size?
if ($aOptions['SizeCustom']) {
$aArgs['stwxmax'] = $aOptions['SizeCustom'];
}
else {
$aArgs['stwsize'] = $aOptions['Size'];
}
}
// Use fullsize capturing?
if ($aOptions['FullSizeCapture']) {
$aArgs['stwfull'] = 1;
if ($aOptions['SizeCustom']) {
$aArgs['stwxmax'] = $aOptions['SizeCustom'];
}
elseif (isset($aOptions['Size'])) {
switch ($aOptions['Size']) {
case 'mcr':
$aArgs['stwxmax'] = 75;
break;
case 'tny':
$aArgs['stwxmax'] = 90;
break;
case 'vsm':
$aArgs['stwxmax'] = 100;
break;
case 'sm':
$aArgs['stwxmax'] = 120;
break;
case 'lg':
$aArgs['stwxmax'] = 200;
break;
case 'xlg':
$aArgs['stwxmax'] = 320;
break;
}
}
if ($aOptions['MaxHeight']) {
$aArgs['stwymax'] = $aOptions['MaxHeight'];
}
}
// Change native resolution?
if ($aOptions['NativeResolution']) {
$aArgs['stwnrx'] = $aOptions['NativeResolution'];
if ($aOptions['WidescreenY']) {
$aArgs['stwnry'] = $aOptions['WidescreenY'];
if ($aOptions['SizeCustom']) {
$aArgs['stwxmax'] = $aOptions['SizeCustom'];
}
elseif (isset($aOptions['Size'])) {
switch ($aOptions['Size']) {
case 'mcr':
$aArgs['stwxmax'] = 75;
break;
case 'tny':
$aArgs['stwxmax'] = 90;
break;
case 'vsm':
$aArgs['stwxmax'] = 100;
break;
case 'sm':
$aArgs['stwxmax'] = 120;
break;
case 'lg':
$aArgs['stwxmax'] = 200;
break;
case 'xlg':
$aArgs['stwxmax'] = 320;
break;
}
}
}
}
// Wait after page load in seconds.
if ($aOptions['Delay']) {
$aArgs['stwdelay'] = intval($aOptions['Delay']) <= 45 ? intval($aOptions['Delay']) : 45;
}
// Use Refresh On-Demand?
if ($aOptions['RefreshOnDemand']) {
$aArgs['stwredo'] = 1;
}
// Use URL-to_PDF?
if ($aOptions['PDF']) {
$aArgs['stwpdf'] = 1;
}
// Use another image quality in percent.
if ($aOptions['Quality']) {
$aArgs['stwq'] = intval($aOptions['Quality']);
}
// Use custom messages?
if (CUSTOM_MSG_URL) {
$aArgs['stwrpath'] = CUSTOM_MSG_URL;
}
// Use callback notification? (no need to check for new requests; they will automatically download).
if (CALLBACKURL) {
$aArgs['stwcallback'] = urlencode(CALLBACKURL . '?token=' . TOKEN);
// Set the callback like: &stwcallback='.urlencode('http://domain.tld/stw_notify.php?token=18298jkjsse3').'&stwparameter=...)
// Your callback MUST be encoded or it may not work with the "notifyNoPush" parameter (to avoid sending data with the notify).
}
// Send the notifyNoPush parameter.
if (NOTIFYNOPUSH) {
$aArgs['stwcallback'] .= ',' . NOTIFYNOPUSH;
// We must use JSON with Base64 encoding, which adds 33% size to the image data. If too great, you may send notifyNoPush as:
// &stwcallback='.urlencode('http://domain.tld/stw_notify.php?token=18298jkjsse3').',1&stwparameter=...) -- notice the comma and 1
}
return $aArgs;
}