本文整理汇总了PHP中jsonRPCClient类的典型用法代码示例。如果您正苦于以下问题:PHP jsonRPCClient类的具体用法?PHP jsonRPCClient怎么用?PHP jsonRPCClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了jsonRPCClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test
/**
* Simple procedure to test most RPC functions
*
*/
public function test()
{
$sFileToImport = dirname(Yii::app()->basePath) . DIRECTORY_SEPARATOR . 'docs' . DIRECTORY_SEPARATOR . 'demosurveys' . DIRECTORY_SEPARATOR . 'limesurvey2_sample_survey_english.lss';
// $sFileToImport=dirname(Yii::app()->basePath).DIRECTORY_SEPARATOR.'docs'.DIRECTORY_SEPARATOR.'demosurveys'.DIRECTORY_SEPARATOR.'survey_archive_example_feedback_survey.zip';
Yii::app()->loadLibrary('jsonRPCClient');
$myJSONRPCClient = new jsonRPCClient(Yii::app()->getBaseUrl(true) . '/' . dirname(Yii::app()->request->getPathInfo()));
$sSessionKey = $myJSONRPCClient->get_session_key('admin', 'password');
if (is_array($sSessionKey)) {
echo $sSessionKey['status'];
die;
} else {
echo 'Retrieved session key' . '<br>';
}
$sLSSData = base64_encode(file_get_contents($sFileToImport));
$iSurveyID = $myJSONRPCClient->import_survey($sSessionKey, $sLSSData, 'zip', 'Test import by JSON_RPC', 1000);
echo 'Created new survey SID:' . $iSurveyID . '<br>';
/*
Very simple example to export responses as Excel file
$aResult=$myJSONRPCClient->export_reponses($sSessionKey,$iSurveyID,'xls');
file_put_contents('d:\test.xls',base64_decode(chunk_split($aResult)));
*/
$aResult = $myJSONRPCClient->activate_survey($sSessionKey, $iSurveyID);
if ($aResult['status'] == 'OK') {
echo 'Survey ' . $iSurveyID . ' successfully activated.<br>';
}
$aResult = $myJSONRPCClient->activate_participant_tokens($sSessionKey, $iSurveyID, array(1, 2));
if ($aResult['status'] == 'OK') {
echo 'Tokens for Survey ID ' . $iSurveyID . ' successfully activated.<br>';
}
$aResult = $myJSONRPCClient->set_survey_properties($sSessionKey, $iSurveyID, array('faxto' => '0800-LIMESURVEY'));
if ($aResult['status'] == 'OK') {
echo 'Modified survey settings for survey ' . $iSurveyID . '<br>';
}
$aResult = $myJSONRPCClient->add_survey_language($sSessionKey, $iSurveyID, 'ar');
if ($aResult['status'] == 'OK') {
echo 'Added Arabian as additional language' . '<br>';
}
$aResult = $myJSONRPCClient->set_survey_language_properties($sSessionKey, $iSurveyID, array('surveyls_welcometext' => 'An Arabian welcome text!'), 'ar');
if ($aResult['status'] == 'OK') {
echo 'Modified survey locale setting welcometext for Arabian in survey ID ' . $iSurveyID . '<br>';
}
$aResult = $myJSONRPCClient->delete_survey_language($sSessionKey, $iSurveyID, 'ar');
if ($aResult['status'] == 'OK') {
echo 'Removed Arabian as additional language' . '<br>';
}
die;
$aResult = $myJSONRPCClient->delete_survey($sSessionKey, $iSurveyID);
echo 'Deleted survey SID:' . $iSurveyID . '-' . $aResult['status'] . '<br>';
// Release the session key - close the session
$Result = $myJSONRPCClient->release_session_key($sSessionKey);
echo 'Closed the session' . '<br>';
}
示例2: confirm_sent
public function confirm_sent()
{
$this->load->model('checkout/order');
$order_id = $this->session->data['order_id'];
$order = $this->model_checkout_order->getOrder($order_id);
$current_default_currency = $this->config->get('config_currency');
$eMark_DEM_decimal = $this->config->get('eMark_DEM_decimal');
$eMark_total = $order['eMark_total'];
$eMark_address = $order['eMark_address'];
require_once 'jsonRPCClient.php';
$eMark = new jsonRPCClient('http://' . $this->config->get('eMark_rpc_username') . ':' . $this->config->get('eMark_rpc_password') . '@' . $this->config->get('eMark_rpc_address') . ':' . $this->config->get('eMark_rpc_port') . '/');
try {
$eMark_info = $eMark->getinfo();
} catch (Exception $e) {
$this->data['error'] = true;
}
try {
$received_amount = $eMark->getreceivedbyaddress($eMark_address, 0);
if (round((double) $received_amount, $eMark_DEM_decimal) >= round((double) $eMark_total, $eMark_DEM_decimal)) {
$order = $this->model_checkout_order->getOrder($order_id);
$this->model_checkout_order->confirm($order_id, $this->config->get('eMark_order_status_id'));
echo "1";
} else {
echo "0";
}
} catch (Exception $e) {
$this->data['error'] = true;
echo "0";
}
}
示例3: bitcoin_link
function bitcoin_link($params)
{
# Gateway Specific Variables
$u = $params['username'];
$p = $params['password'];
$h = $params['host'] . ':' . $params['port'];
$rpc = 'http://' . $u . ':' . $p . '@' . $h;
# Invoice Variables
$invoiceid = $params['invoiceid'];
$amount = $params['amount'];
# Format: ##.##
$currency = $params['currency'];
# Currency Code
# Client Variables
$firstname = $params['clientdetails']['firstname'];
$lastname = $params['clientdetails']['lastname'];
$email = $params['clientdetails']['email'];
$address1 = $params['clientdetails']['address1'];
$address2 = $params['clientdetails']['address2'];
$city = $params['clientdetails']['city'];
$state = $params['clientdetails']['state'];
$postcode = $params['clientdetails']['postcode'];
$country = $params['clientdetails']['country'];
$phone = $params['clientdetails']['phonenumber'];
# Build Bitcoin Information Here
require_once 'bitcoin/jsonRPCClient.php';
$bitcoin = new jsonRPCClient($rpc);
if (!$bitcoin->getinfo()) {
die('could not connect to bitcoind');
}
$address = $bitcoin->getaccountaddress($params['clientdetails']['userid'] . '-' . $invoiceid);
# Enter your code submit to the gateway...
$code = 'Send Payments to: ' . $address . '';
return $code;
}
示例4: 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;
}
}
}
示例5: jsonRPCAct
public function jsonRPCAct()
{
vendor('jsonRPC.jsonRPCClient');
$client = new \jsonRPCClient('http://localhost:8500/Api/JsonRPCTest');
$result = $client->test();
var_dump($result);
// 结果:
}
示例6: test
/**
* Simple procedure to test most RPC functions
*
*/
public function test()
{
$RPCType = Yii::app()->getConfig("RPCInterface");
$serverUrl = Yii::app()->getBaseUrl(true) . '/' . dirname(Yii::app()->request->getPathInfo());
$sFileToImport = dirname(Yii::app()->basePath) . DIRECTORY_SEPARATOR . 'docs' . DIRECTORY_SEPARATOR . 'demosurveys' . DIRECTORY_SEPARATOR . 'limesurvey2_sample_survey_english.lss';
if ($RPCType == 'xml') {
require_once 'Zend/XmlRpc/Client.php';
$client = new Zend_XmlRpc_Client($serverUrl);
} elseif ($RPCType == 'json') {
Yii::app()->loadLibrary('jsonRPCClient');
$client = new jsonRPCClient($serverUrl);
}
$sSessionKey = $client->call('get_session_key', array('admin', 'password'));
if (is_array($sSessionKey)) {
echo $sSessionKey['status'];
die;
} else {
echo 'Retrieved session key' . '<br>';
}
$sLSSData = base64_encode(file_get_contents($sFileToImport));
$iSurveyID = $client->call('import_survey', array($sSessionKey, $sLSSData, 'lss', 'Test import by JSON_RPC', 1000));
echo 'Created new survey SID:' . $iSurveyID . '<br>';
$aResult = $client->call('activate_survey', array($sSessionKey, $iSurveyID));
if ($aResult['status'] == 'OK') {
echo 'Survey ' . $iSurveyID . ' successfully activated.<br>';
}
$aResult = $client->call('activate_tokens', array($sSessionKey, $iSurveyID, array(1, 2)));
if ($aResult['status'] == 'OK') {
echo 'Tokens for Survey ID ' . $iSurveyID . ' successfully activated.<br>';
}
$aResult = $client->call('set_survey_properties', array($sSessionKey, $iSurveyID, array('faxto' => '0800-LIMESURVEY')));
if (!array_key_exists('status', $aResult)) {
echo 'Modified survey settings for survey ' . $iSurveyID . '<br>';
}
$aResult = $client->call('add_language', array($sSessionKey, $iSurveyID, 'ar'));
if ($aResult['status'] == 'OK') {
echo 'Added Arabian as additional language' . '<br>';
}
$aResult = $client->call('set_language_properties', array($sSessionKey, $iSurveyID, array('surveyls_welcometext' => 'An Arabian welcome text!'), 'ar'));
if ($aResult['status'] == 'OK') {
echo 'Modified survey locale setting welcometext for Arabian in survey ID ' . $iSurveyID . '<br>';
}
$aResult = $client->call('delete_language', array($sSessionKey, $iSurveyID, 'ar'));
if ($aResult['status'] == 'OK') {
echo 'Removed Arabian as additional language' . '<br>';
}
//Very simple example to export responses as Excel file
//$aResult=$client->call('export_responses', array($sSessionKey,$iSurveyID,'xls'));
//$aResult=$client->call('export_responses', array($sSessionKey,$iSurveyID,'pdf'));
//$aResult=$client->call('export_responses', array($sSessionKey,$iSurveyID,'doc'));
$aResult = $client->call('export_responses', array($sSessionKey, $iSurveyID, 'csv'));
//file_put_contents('test.xls',base64_decode(chunk_split($aResult)));
$aResult = $client->call('delete_survey', array($sSessionKey, $iSurveyID));
echo 'Deleted survey SID:' . $iSurveyID . '-' . $aResult['status'] . '<br>';
// Release the session key - close the session
$Result = $client->call('release_session_key', array($sSessionKey));
echo 'Closed the session' . '<br>';
}
示例7: transactionLookup
public static function transactionLookup($tx)
{
$wallet = new jsonRPCClient(HOTWALLET, true);
$getRawTransaction = $wallet->getrawtransaction($tx);
$decodeRawTransaction = $wallet->decoderawtransaction($getRawTransaction);
$return['rawtransaction'] = $getRawTransaction;
$return['transaction'] = $decodeRawTransaction;
return $return;
}
示例8: get_block_info
function get_block_info($block){
require_once('/var/www/midas/root/private/class/jsonRPCClient.php');
$darkcoin = new jsonRPCClient('http://xxxx:yyyy@127.0.0.1:9998/');
$hash_block = $darkcoin->getblockhash(intval($block));
$info_block = $darkcoin->getblock($hash_block);
$tx = $info_block["tx"][0];
$diff = round($info_block["difficulty"]);
$last_block = $block_id = $info_block["height"];
$block_time = $info_block["time"];
return $info_block;
}
示例9: sendToAddress
function sendToAddress($address, $amount)
{
try {
$amount = round($amount, 8);
$bitcoin = new jsonRPCClient(kBitcoinURL);
$txid = $bitcoin->sendtoaddress($address, floatval($amount));
$log = new MessageLog('log', 255);
$log->write("mywallet-bitcoin:{$address} BTC:{$amount} txid:{$txid}");
return $txid;
} catch (Exception $e) {
return "Error: " . $e->getMessage();
}
}
示例10: search
/**
* Return an array of objects representing search results.
*
* See: http://www.bugzilla.org/docs/4.2/en/html/api/Bugzilla/WebService/Bug.html#search
*
* @param array $params search fields => values
* @return array of stdClass bug objects for given search
* @return boolean false if search failed altogether (I think)
*/
function search(array $params)
{
$client = new jsonRPCClient("https://bugzilla.wikimedia.org/jsonrpc.cgi");
try {
$result = $client->call('Bug.search', array($params));
} catch (\Exception $e) {
Fail::log($e);
return false;
}
$bugs = array();
for ($i = 0, $c = count($result[1]['bugs']); $i < $c; ++$i) {
$bugs[] = (object) $result[1]['bugs'][$i];
}
return $bugs;
}
示例11: indeed_getResponse
public function indeed_getResponse($api_key, $token, $e_mail, $full_name = '')
{
require_once $this->dir_path . '/email_services/getresponse/jsonRPCClient.php';
$api = new jsonRPCClient('http://api2.getresponse.com');
$args = array('campaign' => $token, 'email' => $e_mail);
if (!empty($full_name)) {
$args['name'] = $full_name;
}
$res = $api->add_contact($api_key, $args);
if ($res) {
return 1;
} else {
return 0;
}
}
示例12: confirm_sent
public function confirm_sent()
{
$this->load->model('checkout/order');
$order_id = $this->session->data['order_id'];
$order = $this->model_checkout_order->getOrder($order_id);
$current_default_currency = $this->config->get('config_currency');
$bitcoin_btc_decimal = $this->config->get('bitcoin_btc_decimal');
$bitcoin_total = $order['bitcoin_total'];
$bitcoin_address = $order['bitcoin_address'];
if (!$this->config->get('bitcoin_blockchain')) {
require_once 'jsonRPCClient.php';
$bitcoin = new jsonRPCClient('http://' . $this->config->get('bitcoin_rpc_username') . ':' . $this->config->get('bitcoin_rpc_password') . '@' . $this->config->get('bitcoin_rpc_address') . ':' . $this->config->get('bitcoin_rpc_port') . '/');
try {
$bitcoin_info = $bitcoin->getinfo();
} catch (Exception $e) {
$this->data['error'] = true;
}
}
try {
if (!$this->config->get('bitcoin_blockchain')) {
$received_amount = $bitcoin->getreceivedbyaddress($bitcoin_address, 0);
} else {
static $ch = null;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; Blockchain.info PHP client; ' . php_uname('s') . '; PHP/' . phpversion() . ')');
curl_setopt($ch, CURLOPT_URL, 'http://blockchain.info/q/getreceivedbyaddress/' . $bitcoin_address . '?confirmations=0');
$res = curl_exec($ch);
if ($res === false) {
throw new Exception('Could not get reply: ' . curl_error($ch));
}
$received_amount = $res / 100000000;
}
if (round((double) $received_amount, $bitcoin_btc_decimal) >= round((double) $bitcoin_total, $bitcoin_btc_decimal)) {
$order = $this->model_checkout_order->getOrder($order_id);
$this->model_checkout_order->confirm($order_id, $this->config->get('bitcoin_order_status_id'));
echo "1";
} else {
echo "0";
}
} catch (Exception $e) {
$this->data['error'] = true;
echo "0";
}
}
示例13: sendBtc
function sendBtc($id, $amount)
{
#Send btc from id to address
$bitcoin = new jsonRPCClient("http://{$bitcoin_user}:{$bitcoin_pass}@127.0.0.1:8332/");
if ($bitcoin->getbalance() < $amount) {
return -1;
}
if (!debit($id, $amount)) {
return -2;
}
$address = getAddress($id);
if ($address == -1) {
return -3;
}
$comment = getUsernameById($id);
$bitcoin->sendtoaddress($address, $amount, $comment);
return 0;
}
示例14: 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;
}
}
示例15: subscribe_get_response
/**
* Subscribes to GetResponse list. Returns either "success" string or error message.
* @return string
*/
function subscribe_get_response($list, $email, $api_key, $name = '-')
{
if (!function_exists('curl_init')) {
return;
}
require_once RAD_RAPIDOLOGY_PLUGIN_DIR . 'subscription/getresponse/jsonrpcclient.php';
$api_url = 'http://api2.getresponse.com';
$name = '' == $name ? '-' : $name;
$client = new jsonRPCClient($api_url);
$result = $client->add_contact($api_key, array('campaign' => $list, 'name' => $name, 'email' => $email));
if (isset($result['result']['queued']) && 1 == $result['result']['queued']) {
$result = 'success';
} else {
if (isset($result['error']['message'])) {
$result = $result['error']['message'];
} else {
$result = 'unknown error';
}
}
return $result;
}