Skip to content

Instantly share code, notes, and snippets.

@gitfvb
Last active October 25, 2019 16:12
Show Gist options
  • Save gitfvb/79e1e417be551a94c8c59360d37c2495 to your computer and use it in GitHub Desktop.
Save gitfvb/79e1e417be551a94c8c59360d37c2495 to your computer and use it in GitHub Desktop.
calling mailingwork via powershell
[System.Uri]$endpoint = "https://login.mailingwork.de/webservice/webservice/json/"
$verb = 'getmailings'
$params = @{
username='<username>'
password='<password>'
}
$result = Invoke-RestMethod -Uri "$($endpoint)$($verb)" -Method POST -Body $params -Verbose
$result | Select -expand result
<#
notes
https://login.mailingwork.de/webservice/webservice/demo/?sid=e95c7c63be495403d259d0856c6422e3fc638589
#>
<#
$params=array (
'username' => '<username>',
'password' => '<password>',
'emailId' => 751,
'fields' =>
array (
1 => '[email protected]',
3 => 'Max',
),
'email' => '<email>',
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://login.mailingwork.de/webservice/webservice/json/sendemailbyidandrecipient');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
$result = json_decode(curl_exec($ch),true);
$error = curl_error($ch);
print "errorcode:".$result['error']."\n";
print "message:".$result['message']."\n";
print "result:".print_r($result['result'],true)."\n";
if ($error) print $error."\n";
#>
<#
get lists
#>
$baseParams = @{
"username" = "<username>"
"password" = "<password>"
}
$params = $baseParams
$base = "https://login.mailingwork.de/webservice/webservice/json/"
$verb = "getlists"
$res = Invoke-RestMethod -Uri "$( $base )$( $verb )" -Method Post -Body $params -Verbose
$res.result
<#
get mailings
#>
$params = $baseparams + @{
"advanced[status]" = "activated"
"advanced[type]" = "campaign"
}
$verb = "getmailings"
$res = Invoke-RestMethod -Uri "$( $base )$( $verb )" -Method Post -Body $params -Verbose #-ContentType "application/json"
# TODO [ ] add additional exception handler
if ( $res.error -eq 0 ) {
$res.result
} else {
"error: $( $res.error ) - $( $res.message )"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment