本文整理汇总了PHP中jsonRPCClient::call方法的典型用法代码示例。如果您正苦于以下问题:PHP jsonRPCClient::call方法的具体用法?PHP jsonRPCClient::call怎么用?PHP jsonRPCClient::call使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jsonRPCClient
的用法示例。
在下文中一共展示了jsonRPCClient::call方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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>';
}
示例2: 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;
}
示例3: search_gerrit
function search_gerrit()
{
$client = new jsonRPCClient("https://gerrit.wikimedia.org/r/gerrit/rpc/ChangeListService");
try {
$result = $client->call('allQueryNext', array());
} 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;
}