本文整理汇总了PHP中jsonRPCClient::get_campaigns方法的典型用法代码示例。如果您正苦于以下问题:PHP jsonRPCClient::get_campaigns方法的具体用法?PHP jsonRPCClient::get_campaigns怎么用?PHP jsonRPCClient::get_campaigns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsonRPCClient
的用法示例。
在下文中一共展示了jsonRPCClient::get_campaigns方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AutoResponderGetResponseAPI
function AutoResponderGetResponseAPI($that, $ar, $wpm_id, $email, $unsub = false)
{
global $wpdb;
require_once $that->pluginDir . '/extlib/jsonRPCClient.php';
if ($ar['campaign'][$wpm_id]) {
$campaign = trim($ar['campaign'][$wpm_id]);
$name = trim($that->ARSender['name']);
$email = trim($that->ARSender['email']);
$api_key = trim($ar['apikey']);
$api_url = empty($ar['api_url']) ? "http://api2.getresponse.com" : trim($ar['api_url']);
$grUnsub = $ar['grUnsub'][$wpm_id] == 1 ? true : false;
$uid = $wpdb->get_var("SELECT ID FROM {$wpdb->users} WHERE `user_email`='" . esc_sql($that->ARSender['email']) . "'");
$ip = trim($that->Get_UserMeta($uid, 'wpm_login_ip'));
$ip = $ip ? $ip : trim($that->Get_UserMeta($uid, 'wpm_registration_ip'));
$ip = $ip ? $ip : trim($_SERVER['REMOTE_ADDR']);
try {
if (!extension_loaded('curl') || !extension_loaded('json')) {
# these extensions are a must
throw new Exception("CURL and JSON are modules required to use" . " the GetResponse Integration");
}
$api = new jsonRPCClient($api_url);
#get the campaign id
$resp = $api->get_campaigns($api_key);
$cid = null;
if (!empty($resp)) {
foreach ($resp as $i => $item) {
if (strtolower($item['name']) == strtolower($campaign)) {
$cid = $i;
}
}
}
if (empty($cid)) {
throw new Exception("Could not find campaign {$campaign}");
}
if ($unsub) {
if ($grUnsub) {
//list contacts
$contacts = $api->get_contacts($api_key, array('campaigns' => array($cid), 'email' => array('EQUALS' => "{$email}")));
if (empty($contacts)) {
#could not find the contact, nothing to remove
return;
}
$pid = key($contacts);
$res = $api->delete_contact($api_key, array('contact' => $pid));
if (empty($res)) {
throw new Exception("Empty server response while deleting contact");
}
}
} else {
$resp = $api->add_contact($api_key, array('campaign' => $cid, 'name' => $name, 'email' => $email, 'ip' => $ip, 'cycle_day' => 0));
if (empty($resp)) {
throw new Exception("Empty server response while sending");
}
}
} catch (Exception $e) {
return;
}
}
}
示例2: process
function process()
{
global $order;
if (!$this->enabled) {
return;
}
$client = new jsonRPCClient('http://api2.getresponse.com');
$result = NULL;
try {
$result = $client->get_campaigns(MODULE_ORDER_TOTAL_GETRESPONSE_API_KEY, array('name' => array('EQUALS' => MODULE_ORDER_TOTAL_GETRESPONSE_CAMPAIGN)));
if (empty($result)) {
throw new Exception('Missing GetResponse campaign: ' . MODULE_ORDER_TOTAL_GETRESPONSE_CAMPAIGN);
}
$client->add_contact(MODULE_ORDER_TOTAL_GETRESPONSE_API_KEY, array('campaign' => array_pop(array_keys($result)), 'name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'email' => $order->customer['email_address'], 'cycle_day' => '0', 'customs' => array(array('name' => 'ref', 'content' => STORE_NAME), array('name' => 'telephone', 'content' => $order->customer['telephone']), array('name' => 'country', 'content' => $order->customer['country']['title']), array('name' => 'city', 'content' => $order->customer['city']))));
} catch (Exception $e) {
error_log($e->getMessage());
return;
}
}
示例3: get_getresponse_lists
/**
* Get all Get Repsonse Lists and display in settings
*
*/
public function get_getresponse_lists() {
$options = '';
if (isset($_POST['api_key']) && $_POST['api_key'] != '') {
require_once( 'includes/getresponse/jsonRPCClient.php');
$api = new jsonRPCClient('http://api2.getresponse.com');
try {
$result = $api->get_campaigns(sanitize_text_field( $_POST['api_key'] ));
foreach ((array) $result as $k => $v) {
$campaigns[] = array('id' => $k, 'name' => $v['name']);
}
}
catch (Exception $e) {}
if (isset($campaigns) && is_array($campaigns)) {
foreach ($campaigns as $campaign) {
$options .= '<option value="' . $campaign['id'] . '">' . $campaign['name'] . '</option>';
}
if (isset($_POST['campaign']) && $_POST['campaign'] != '') {
$options = '';
foreach ($campaigns as $campaign) {
if ($_POST['campaign'] == $campaign['id']) {
$options .= '<option value="' . $campaign['id'] . '" selected="selected">' . $campaign['name'] . '</option>';
} else {
$options .= '<option value="' . $campaign['id'] . '">' . $campaign['name'] . '</option>';
}
}
}
}
}
echo $options;
die(); // this is required to terminate immediately and return a proper response
}
示例4: jsonRPCClient
*/
# JSON-RPC module is required
# available at http://github.com/GetResponse/DevZone/blob/master/API/lib/jsonRPCClient.php
# alternate version available at http://jsonrpcphp.org/
require_once 'jsonRPCClient.php';
# your API key
# available at http://www.getresponse.com/my_api_key.html
$api_key = 'ENTER_YOUR_API_KEY_HERE';
# API 2.x URL
$api_url = 'http://api2.getresponse.com';
# initialize JSON-RPC client
$client = new jsonRPCClient($api_url);
$result = NULL;
# get CAMPAIGN_ID of 'sample_marketing' campaign
try {
$result = $client->get_campaigns($api_key, array('name' => array('EQUALS' => 'sample_marketing')));
} catch (Exception $e) {
# check for communication and response errors
# implement handling if needed
die($e->getMessage());
}
# uncomment this line to preview data structure
# print_r($result);
# since there can be only one campaign of this name
# first key is the CAMPAIGN_ID you need
$campaigns = array_keys($result);
$CAMPAIGN_ID = array_pop($campaigns);
# add contact to 'sample_marketing' campaign
try {
$result = $client->add_contact($api_key, array('campaign' => $CAMPAIGN_ID, 'name' => 'Sample Name', 'email' => 'sample@email.com', 'cycle_day' => '0', 'customs' => array(array('name' => 'last_purchased_product', 'content' => 'netbook'))));
} catch (Exception $e) {
示例5: snp_ml_get_gr_lists
function snp_ml_get_gr_lists($ml_gr_apikey = '')
{
require_once SNP_DIR_PATH . '/include/getresponse/jsonRPCClient.php';
$list = array();
if (snp_get_option('ml_gr_apikey') || $ml_gr_apikey) {
if (!$ml_gr_apikey) {
$ml_gr_apikey = snp_get_option('ml_gr_apikey');
}
$api = new jsonRPCClient('http://api2.getresponse.com');
try {
$result = $api->get_campaigns($ml_gr_apikey);
foreach ((array) $result as $k => $v) {
$list[$k] = array('name' => $v['name']);
}
} catch (Exception $e) {
//die($e->getMessage());
// Error
}
}
if (count($list) == 0) {
$list[0] = array('name' => 'Nothing Found...');
}
return $list;
}
示例6: switch
}
if(isset($_POST['mailer']) and isset($_POST['apikey']) and isset($_POST['connect'])){
$mailer_id = $_POST['mailer'];
$api_key = $_POST['apikey'];
switch($mailer_id){
//GetResponse
case 1: if (!class_exists('jsonRPCClient')) {
include_once(plugin_dir_path(dirname(__FILE__)).'mailers/getresponse-api.php');
}
$getresponse = new jsonRPCClient('http://api2.getresponse.com');
try{
$name = array();
$allgrcampaigns = $getresponse->get_campaigns($api_key);
foreach($allgrcampaigns as $grcampaign){
$campaign_name = $grcampaign['name'];
$result = $getresponse->get_campaigns($api_key, array ('name' => array ( 'EQUALS' => $campaign_name )));
$res = array_keys($result);
$campaign_id = array_pop($res);
$getresponse_campaigns[$campaign_id] = $campaign_name;
}
$getresponse_campaigns = serialize($getresponse_campaigns);
update_option('wpcb_getresponse_api_key',$api_key);
update_option('wpcb_getresponse_campaigns',$getresponse_campaigns);
$showresponse_1 = "<div class='wpcb_success' style='margin: 0px 10px 10px 10px;'><p>". __('Connected to API successfully.', 'wp-conversion-boxes') ."<a href='' style='float:right;' onclick='jQuery(this).parent().parent().fadeOut(300).hide();'>Close</a></p></div>";
}
catch (Exception $e){
echo $e->getMessage();
$showresponse_1 = "<div id='wpcb_error' style='margin: 0px 10px 10px 10px;'><p>". __('Invalid API Key. Please try again.', 'wp-conversion-boxes') ."<a href='' style='float:right;' onclick='jQuery(this).parent().parent().fadeOut(300).hide();'>Close</a></p></div>";
示例7: export
public function export()
{
$this->load->model('module/getresponse');
$contacts = $this->model_module_getresponse->getContacts();
$this->gr_apikey = $this->request->post['api_key'];
$this->campaign = $this->request->post['campaign'];
$this->load->library('jsonRPCClient');
try {
$client = new jsonRPCClient($this->gr_apikey_url);
$result = $client->get_campaigns($this->gr_apikey, array('name' => array('EQUALS' => $this->campaign)));
} catch (Exception $e) {
$this->data['error_warning'] = 'Error!' . $e;
}
if (empty($result)) {
$results = array('status' => 2, 'response' => ' No campaign with the specified name.');
} else {
$duplicated = 0;
$queued = 0;
$contact = 0;
$not_added = 0;
$allow_fields = array('telephone', 'country', 'city', 'address', 'postcode');
$campaign_id = key($result);
foreach ($contacts as $row) {
$customs = array();
$customs[] = array('name' => 'ref', 'content' => 'OpenCart');
foreach ($allow_fields as $af) {
if (!empty($row[$af])) {
$customs[] = array('name' => $af, 'content' => $row[$af]);
}
}
$check_cycle_day = $client->get_contacts($this->gr_apikey, array('campaigns' => array($campaign_id), 'email' => array('EQUALS' => $row['email'])));
if (!empty($check_cycle_day) and is_array($check_cycle_day)) {
$res = array_shift($check_cycle_day);
$cycle_day = $res['cycle_day'];
} else {
$cycle_day = '0';
}
$params = array('campaign' => $campaign_id, 'name' => $row['firstname'] . ' ' . $row['lastname'], 'email' => $row['email'], 'cycle_day' => $cycle_day, 'customs' => $customs);
try {
$r = $client->add_contact($this->gr_apikey, $params);
$contact++;
if (array_key_exists('queued', $r)) {
$queued++;
} else {
if (array_key_exists('duplicated', $r)) {
$duplicated++;
}
}
} catch (Exception $e) {
$not_added++;
}
}
$results = array('status' => 1, 'response' => ' Export completed. Contacts: ' . $contact . '. Queued:' . $queued . '. Updated: ' . $duplicated . '. Not added (Contact already queued): ' . $not_added . '.');
}
$this->response->setOutput(json_encode($results));
}
示例8: affwp_getresponse_get_campaigns
public function affwp_getresponse_get_campaigns()
{
if (!class_exists('jsonRPCClient')) {
require_once 'classes/jsonRPCClient.php';
}
$api_url = 'http://api2.getresponse.com';
$client = new jsonRPCClient($api_url);
try {
$getresponse_api_key = affiliate_wp()->settings->get('affwp_getresponse_api_key');
$getresponse_api_key = trim($getresponse_api_key);
$getresponse_campaigns = array();
$campaigns = $client->get_campaigns($getresponse_api_key);
foreach ($campaigns as $key => $value) {
$getresponse_campaigns[$key] = $value['name'];
}
return $getresponse_campaigns;
} catch (Exception $e) {
return false;
}
}
示例9: dirname
/**
* Get all Get Repsonse Lists and display in settings
*
* @access public
* @return void
*/
function nnr_new_int_get_getresponse_lists_v1()
{
do_action('nnr_news_int_before_get_getresponse_lists_v1');
$options = '';
if (isset($_POST['api_key']) && $_POST['api_key'] != '') {
require_once dirname(dirname(__FILE__)) . '/services/getresponse/jsonRPCClient.php';
$api = new jsonRPCClient('http://api2.getresponse.com');
try {
$result = $api->get_campaigns($_POST['api_key']);
foreach ((array) $result as $k => $v) {
$campaigns[] = array('id' => $k, 'name' => $v['name']);
}
} catch (Exception $e) {
}
if (isset($campaigns) && is_array($campaigns)) {
foreach ($campaigns as $campaign) {
$options .= '<option value="' . $campaign['id'] . '">' . $campaign['name'] . '</option>';
}
if (isset($_POST['campaign']) && $_POST['campaign'] != '') {
$options = '';
foreach ($campaigns as $campaign) {
if ($_POST['campaign'] == $campaign['id']) {
$options .= '<option value="' . $campaign['id'] . '" selected="selected">' . $campaign['name'] . '</option>';
} else {
$options .= '<option value="' . $campaign['id'] . '">' . $campaign['name'] . '</option>';
}
}
}
}
}
do_action('nnr_news_int_after_get_getresponse_lists_v1');
echo apply_filters('nnr_news_int_get_getresponse_lists_v1', $options);
die;
// this is required to terminate immediately and return a proper response
}