我试图使用此代码将错误发布到我的bugzilla帐户
set_time_limit(0);
$URI = 'http://site.com/bugzilla/xmlrpc.cgi';
$xml_data = array(
'login' => 'email',
'password' => 'password',
'remember' => 0
);
$bug_ids = array(50, 100); // bugs list
//$file_cookie = tempnam('', 'bugzilla-cookie');
$ch = curl_init();
$options = array(
//CURLOPT_VERBOSE => true,
CURLOPT_URL => $URI,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array( 'Content-Type: text/xml', 'charset=utf-8' )
);
curl_setopt($ch, CURLOPT_TIMEOUT,60);
curl_setopt_array($ch, $options);
$request = xmlrpc_encode_request("User.login", $xml_data);
var_dump($request);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
//curl_setopt($ch, CURLOPT_COOKIEJAR, $file_cookie);
$server_output = curl_exec($ch); // Array( [id] => 1 ) for example
print_r ($server_output);
$response = xmlrpc_decode($server_output);
但它一直在请求,我没有得到回复
我还阅读了BugZilla的文档,但我从中得不到任何内容
我还找到了Zend框架的代码
$oClient = new Zend_XmlRpc_Client('http://my.zilla.url/xmlrpc.cgi');
$oHttpClient = new Zend_Http_Client();
$oHttpClient->setCookieJar();
$oClient->setHttpClient($oHttpClient);
$aResponse = $oClient->call('User.login', array(array(
'login' => 'peterh@mydomain.com',
'password' => 'mypassword',
'remember' => 1
)));
$aResponse = $oClient->call('Bug.create', array(array(
'product' => "My Product",
'component' => "My Component",
'summary' => "This is the summary of the bug I'm creating",
'version' => "unspecified",
'description' => "This is a description of the bug",
'op_sys' => "All",
'platform' => "---",
'priority' => "P5",
'severity' => "Trivial"
)));
$iBugId = $aResponse['id'];
$aResponse = $oClient->call('User.logout');
但我没有使用Zend框架
我读过时还有一些perl文件,但我不知道如何处理它们
经过三天的搜索和阅读,我来到这里 请帮我完成它
答案 0 :(得分:3)
我使用此代码在bugzilla中创建错误...我希望这对某人有用
set_time_limit(0);
$URI = 'your bugzilla url/xmlrpc.cgi';
$xml_data = array(
'login' => 'username',
'password' => 'password',
'remember' => 0
);
$ch = curl_init();
$file_cookie = tempnam('', 'bugzilla-cookie');
$options = array(
//CURLOPT_VERBOSE => true,
CURLOPT_URL => $URI,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array( 'Content-Type: text/xml', 'charset=utf-8' )
);
curl_setopt($ch, CURLOPT_TIMEOUT,60);
curl_setopt_array($ch, $options);
$request = xmlrpc_encode_request("User.login", $xml_data);
// var_dump($request);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_COOKIEJAR, $file_cookie);
$server_output = curl_exec($ch); // Array( [id] => 1 ) for example
print_r ($server_output);
echo "<br />";
$response = xmlrpc_decode($server_output);
print_r ($response);
$xml_data1 = array(
'product' => "Magento",
'component' => "Menu",
'summary' => "this is third testing bug",
'assigned_to' => "assigneename",
'version' => "1.6.2.0",
'description' => "This is a description of the bug",
'op_sys' => "All",
'platform' => "All",
'priority' => "Normal",
'severity' => "Trivial"
);
$request = xmlrpc_encode_request("Bug.create", $xml_data1); // create a request for filing bugs
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$response = xmlrpc_decode(curl_exec($ch));
print_r ($response);
答案 1 :(得分:0)
以下文档重点介绍如何创建XML-RPC服务器,但最后显示了使用生成的XML-RPC服务的示例。
the Bakery - How to create an XML-RPC server with CakePHP
该类可能会有所帮助,因为您需要连接到XML-RPC服务器(bugzilla)