Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for bulk operations #37

Open
dardoguidobono opened this issue Aug 16, 2016 · 0 comments
Open

Support for bulk operations #37

dardoguidobono opened this issue Aug 16, 2016 · 0 comments

Comments

@dardoguidobono
Copy link
Contributor

dardoguidobono commented Aug 16, 2016

Support for bulk operations see pr ( work in progress )
Thnks.

Example call:

`<?php
$subscribers = [
[
'email' => 'dardoguidobono+1@gmail.com',
'confirmed' => 1,
'htmlemail' => 1,
'password' => '',
'disabled' => 0,
'foreignkey' => '',
'subscribepage' => 0,
],
[
'email' => 'dardoguidobono+2@gmail.com',
'confirmed' => 1,
'htmlemail' => 1,
'password' => '',
'disabled' => 0,
'foreignkey' => '',
'subscribepage' => 0,
]

];
$url = 'http://xxxx/lists/admin/?page=call&pi=restapi';

//initialize cUrl for remote content
$c = curl_init();
curl_setopt( $c, CURLOPT_COOKIEFILE, 'phpList_RESTAPI_Helper' );
curl_setopt( $c, CURLOPT_COOKIEJAR, 'phpList_RESTAPI_Helper' );
curl_setopt( $c, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $c, CURLOPT_POST, 1 );

//Call for the session-id via /login
curl_setopt( $c, CURLOPT_URL, $url );
curl_setopt( $c, CURLOPT_POSTFIELDS, 'cmd=login&login=admin&password=xxxx' );
$result = curl_exec( $c );
$result = json_decode( $result );
//Get all lists in phpList via /listsGet
curl_setopt( $c, CURLOPT_URL, $url );
curl_setopt( $c, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $c, CURLOPT_POST, 1 );
curl_setopt( $c, CURLOPT_POSTFIELDS, "cmd=subscriberBulkAdd&subscribers=".urlencode(json_encode($subscribers)) );
$result = curl_exec( $c );
$result = json_decode( $result );

//Now close the cUrl when finished
curl_close( $c );

//Dump all lists in phpList via /listsGet
var_dump( $result->data );`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant