'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array(), 'body' => $param, 'cookies' => array() ) ); /* $curl = curl_init( 'https://app.apptuse.com/plugin-signup/6' ); curl_setopt( $curl, CURLOPT_POST, true ); curl_setopt( $curl, CURLOPT_POSTFIELDS, $param ); curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true ); $response = curl_exec( $curl ); curl_close( $curl ); */ $json_response= json_decode($response,true); if($json_response['success'] == true){ add_option('apptuse_token',$json_response['token']); } } } /*Generate Wordpress API keys */ function apptuse_generateWCAPIKeys(){ global $wpdb; $api_data["shop_url"] = get_option('siteurl'); $api_data["consumer_key"] = 'ck_'.wc_rand_hash(); $api_data["consumer_secret"] = 'cs_'.wc_rand_hash(); $consumer_key = $api_data["consumer_key"]; $consumer_secret = $api_data["consumer_secret"]; $user = get_user_by('email' ,get_option('admin_email')); $data = array( 'user_id' => $user->ID, 'description' => 'apptuse', 'permissions' => "read_write", 'consumer_key' => wc_api_hash($api_data["consumer_key"]), 'consumer_secret' => $api_data["consumer_secret"], 'truncated_key' => substr($api_data["consumer_key"], -7) ); $response= $wpdb->insert( $wpdb->prefix.'woocommerce_api_keys', $data, array( '%d','%s','%s','%s','%s','%s')); return $api_data; }