本文整理汇总了PHP中php_xmlrpc_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP php_xmlrpc_encode函数的具体用法?PHP php_xmlrpc_encode怎么用?PHP php_xmlrpc_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了php_xmlrpc_encode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getcomments
function getcomments($m)
{
global $xmlrpcerruser;
$err = "";
$ra = array();
// get the first param
if (XMLRPC_EPI_ENABLED == '1') {
$msgID = xmlrpc_decode($m->getParam(0));
} else {
$msgID = php_xmlrpc_decode($m->getParam(0));
}
$dbh = dba_open("/tmp/comments.db", "r", "db2");
if ($dbh) {
$countID = "{$msgID}_count";
if (dba_exists($countID, $dbh)) {
$count = dba_fetch($countID, $dbh);
for ($i = 0; $i < $count; $i++) {
$name = dba_fetch("{$msgID}_name_{$i}", $dbh);
$comment = dba_fetch("{$msgID}_comment_{$i}", $dbh);
// push a new struct onto the return array
$ra[] = array("name" => $name, "comment" => $comment);
}
}
}
// if we generated an error, create an error return response
if ($err) {
return new xmlrpcresp(0, $xmlrpcerruser, $err);
} else {
// otherwise, we create the right response
// with the state name
return new xmlrpcresp(php_xmlrpc_encode($ra));
}
}
开发者ID:partisan-collective,项目名称:partisan,代码行数:33,代码来源:discuss.php
示例2: syncStoreAtOdoo
public function syncStoreAtOdoo($store_data)
{
$response = 0;
$auto_warehouse_generation = Mage::getStoreConfig('magerpsync/mobmultishop/auto_warehouse_generation');
$auto_pricelist_generation = Mage::getStoreConfig('magerpsync/mobmultishop/auto_pricelist_generation');
$store_data['auto_warehouse'] = $auto_warehouse_generation;
$store_data['auto_pricelist'] = $auto_pricelist_generation;
$store_array = php_xmlrpc_encode($store_data);
$helper = Mage::helper('magerpsync/connection');
$context = $helper->getOdooContext();
$client = $helper->getClientConnect();
$userId = Mage::getSingleton('adminhtml/session')->getUserId();
$msg = new xmlrpcmsg('execute');
$msg->addParam(new xmlrpcval($helper::$odoo_db, "string"));
$msg->addParam(new xmlrpcval($userId, "int"));
$msg->addParam(new xmlrpcval($helper::$odoo_pwd, "string"));
$msg->addParam(new xmlrpcval("magento.store.view", "string"));
$msg->addParam(new xmlrpcval("sync_store_view", "string"));
$msg->addParam($store_array);
$msg->addParam(new xmlrpcval($context, "struct"));
$resp = $client->send($msg);
if ($resp->faultCode()) {
$error = "Sync Error, Store " . $store_data['name'] . " >>" . $resp->faultString();
Mage::log($error, null, 'odoo_connector.log');
} else {
$response = 1;
$odoo_id = $resp->value()->me["int"];
$store = Mage::getModel("mobmultishop/mobmultishop");
$store->setOdooStoreId($odoo_id);
$store->setMageStoreId($store_data['store_id']);
$store->setCreatedBy($helper::$mage_user);
$store->save();
}
return $response;
}
开发者ID:babycarenl,项目名称:360,代码行数:35,代码来源:Mobmultishop.php
示例3: call
function call($method_name, &$args)
{
$xmlrpc_args = array();
foreach ($args as $arg) {
$xmlrpc_args[] = php_xmlrpc_encode($arg);
}
$xmlrpc_return = $this->client->send(new xmlrpcmsg($method_name, $xmlrpc_args), 300);
return $xmlrpc_return->value();
}
开发者ID:ratbird,项目名称:hope,代码行数:9,代码来源:xml_rpc_webservice_client.php
示例4: addArg
/**
* addArg adds an argument to the args array to pass to the function
*
* @param variable args - Either a single argument or an array of arguments
*/
function addArg()
{
$func_args = func_get_args();
$func_args = $func_args[0];
if (is_array($func_args)) {
foreach ($func_args as $arg) {
$this->_args[] = php_xmlrpc_encode($arg);
}
} else {
$this->_args[] = php_xmlrpc_encode($func_args);
}
}
开发者ID:n2i,项目名称:xvnkb,代码行数:17,代码来源:client.php
示例5: exec
function exec($method, $params = NULL)
{
$message = new xmlrpcmsg($method);
if ($params && is_array($params)) {
foreach ($params as $value) {
$message->addParam(php_xmlrpc_encode($value));
}
}
$result = $this->db->send($message, 15);
if ($result->faultCode()) {
throw new Exception($result->faultString());
}
return $result->value();
}
开发者ID:karepwes,项目名称:OcsPanels,代码行数:14,代码来源:webmin.php
示例6: getTagId
function getTagId($tag)
{
global $client, $key;
$call = new xmlrpcmsg("DataService.query", array(php_xmlrpc_encode($key), php_xmlrpc_encode("ContactGroup"), php_xmlrpc_encode(5000), php_xmlrpc_encode(0), php_xmlrpc_encode(array('Id' => '%')), php_xmlrpc_encode(array('Id', 'GroupName')), php_xmlrpc_encode('GroupName'), php_xmlrpc_encode(true)));
###Send the call###
$result = $client->send($call);
$tagArray = $result->val;
for ($i = 0; $i < count($tagArray); ++$i) {
if ($tagArray[$i]["GroupName"] == $tag) {
$tagId = $tagArray[$i]["Id"];
}
}
return $tagId;
}
开发者ID:RiquelmyMelara,项目名称:Awakened-Millionaire,代码行数:14,代码来源:functions.php
示例7: dispatch
/**
* <MethodDescription>
*
* @param string <description>
*
* @return mixed <description>
*/
function dispatch($msg = NULL)
{
# ensure correct invocation
if (is_null($msg) || !is_a($msg, 'xmlrpcmsg')) {
return $this->throw_exception('functions_parameters_type must not be ' . 'phpvals.');
}
# get decoded parameters
$len = $msg->getNumParams();
$argument_array = array();
for ($i = 0; $i < $len; ++$i) {
$argument_array[] = php_xmlrpc_decode($msg->getParam($i));
}
# return result
return new xmlrpcresp(php_xmlrpc_encode($this->invoke($msg->method(), $argument_array)));
}
开发者ID:ratbird,项目名称:hope,代码行数:22,代码来源:xmlrpc_dispatcher.php
示例8: addCamp
function addCamp($CID, $CMP)
{
###Set up global variables###
global $client, $key;
###Set up the call to add to the campaign###
$call = new xmlrpcmsg("ContactService.addToCampaign", array(php_xmlrpc_encode($key), php_xmlrpc_encode($CID), php_xmlrpc_encode($CMP)));
###Send the call###
$result = $client->send($call);
if (!$result->faultCode()) {
print "Contact added to Campaign " . $CMP;
print "<BR>";
} else {
print $result->faultCode() . "<BR>";
print $result->faultString() . "<BR>";
}
}
开发者ID:nickellison,项目名称:API-Sample-Code,代码行数:16,代码来源:ContactService-Sample.php
示例9: sendXmlRpc
function sendXmlRpc($sMessage, $aParam)
{
$r_client = new xmlrpc_client(ADDR_XMLRPC_ENTERPOINT, ADDR_XMLRPC_SERVER, 80);
foreach ($aParam as $k => $v) {
$aParam[$k] = php_xmlrpc_encode($v);
}
$r_message = new xmlrpcmsg($sMessage, $aParam);
//$c->setDebug(1);
$response =& $r_client->send($r_message);
if ($response->faultCode()) {
return $response;
return 'xmlrpc-error: ' . $file . ' [' . $r->faultCode() . '] ' . $r->faultString();
}
$value = $response->value();
return php_xmlrpc_decode($value);
}
开发者ID:rigidus,项目名称:cobutilniki,代码行数:16,代码来源:update.php
示例10: addCard
function addCard($CC)
{
global $client, $key;
###Set up the call to add the card###
$call = new xmlrpcmsg("DataService.add", array(php_xmlrpc_encode($key), php_xmlrpc_encode("CreditCard"), php_xmlrpc_encode($CC)));
###Send the call###
$result = $client->send($call);
if (!$result->faultCode()) {
$cardID = $result->value();
print "Credit Card added - ID: " . $cardID;
print "<BR>";
} else {
print $result->faultCode() . "<BR>";
print $result->faultString() . "<BR>";
}
return $cardID;
}
开发者ID:luka-php,项目名称:API-Sample-Code,代码行数:17,代码来源:DataService-Sample.php
示例11: addOrderItem
function addOrderItem($oID, $pID, $Type, $Price, $qty, $desc, $notes)
{
global $client, $key;
### Set up the call to add an item ###
$call = new xmlrpcmsg("InvoiceService.addOrderItem", array(php_xmlrpc_encode($key), php_xmlrpc_encode($oID), php_xmlrpc_encode($pID), php_xmlrpc_encode($Type), php_xmlrpc_encode($Price), php_xmlrpc_encode($qty), php_xmlrpc_encode($desc), php_xmlrpc_encode($notes)));
###Send the call###
$result = $client->send($call);
if (!$result->faultCode()) {
$itemID = $result->value();
print "Order Item added: " . $desc;
print "<BR>";
return $itemID;
} else {
print $result->faultCode() . "<BR>";
print $result->faultString() . "<BR>";
}
}
开发者ID:luka-php,项目名称:API-Sample-Code,代码行数:17,代码来源:ProcessSale.php
示例12: buildOrder
function buildOrder($cID, $desc, $oDate, $leadAff, $saleAff)
{
global $client, $key;
###Set up the call to add an order to a contact###
$call = new xmlrpcmsg("InvoiceService.createBlankOrder", array(php_xmlrpc_encode($key), php_xmlrpc_encode($cID), php_xmlrpc_encode($desc), php_xmlrpc_encode($oDate, array('auto_dates')), php_xmlrpc_encode($leadAff), php_xmlrpc_encode($saleAff)));
###Send the call###
$result = $client->send($call);
if (!$result->faultCode()) {
$ordID = $result->value();
print "Blank order built - ID: " . $ordID;
print "<BR>";
return $ordID;
} else {
print $result->faultCode() . "<BR>";
print $result->faultString() . "<BR>";
}
}
开发者ID:luka-php,项目名称:API-Sample-Code,代码行数:17,代码来源:InvoiceService-Sample.php
示例13: xmlrpccall_simple
/**
* Takes a client object, a remote method name, and a variable numbers of
* php values, and calls the method with the supplied parameters. The
* parameters are native php values and the result is an xmlrpcresp object.
*
* Notes:
* The function encodes the received parameters using php_xmlrpc_encode:
* the limitations of automatic encoding apply to this function too);
*
* the type of the value returned by the function can be changed setting
* beforehand the 'return_type' member of the client object to 'phpvals' -
* see the manual for more details about this capability).
*
*
* @author Toth Istvan
*
* @param xmlrpc_client client object, properly set up to connect to server
* @param string remote function name
* @param mixed $parameter1
* @param mixed $parameter2
* @param mixed $parameter3 ...
* @return xmlrpcresp or false on error
*/
function xmlrpccall_simple()
{
if (func_num_args() < 2) {
// Incorrect
return false;
} else {
$varargs = func_get_args();
$client = array_shift($varargs);
$remote_function_name = array_shift($varargs);
if (!is_a($client, 'xmlrpc_client') || !is_string($remote_function_name)) {
return false;
}
$xmlrpcval_array = array();
foreach ($varargs as $parameter) {
$xmlrpcval_array[] = php_xmlrpc_encode($parameter);
}
return $client->send(new xmlrpcmsg($remote_function_name, $xmlrpcval_array));
}
}
开发者ID:caseysoftware,项目名称:web2project-planner,代码行数:42,代码来源:simple_call.php
示例14: sendWithoutAddingKey
public function sendWithoutAddingKey($method, $args, $retry = false)
{
$encoded_arguments = array();
foreach ($args as $argument) {
$encoded_arguments[] = php_xmlrpc_encode($argument, array('auto_dates'));
}
$call = new xmlrpcmsg($method, $encoded_arguments);
$attempts = 0;
$start = time();
$req = null;
do {
if ($attempts > 0) {
if (class_exists('CakeLog') && $attempts > 1) {
$lastAttemptFaultCode = $req->faultCode();
$lastAttemptFaultString = $req->faultString();
}
sleep(5);
}
$attempts++;
$req = $this->client->send($call, $this->timeout, 'https');
} while ($retry && ($req->faultCode() == $GLOBALS['xmlrpcerr']['invalid_return'] || $req->faultCode() == $GLOBALS['xmlrpcerr']['curl_fail'] || strpos($req->faultString(), 'com.infusionsoft.throttle.ThrottlingException: Maximum number of threads throttled') !== false) && $attempts < 3);
$this->totalHttpCalls += $attempts;
if (!$req->faultCode()) {
$result = php_xmlrpc_decode($req->value());
} else {
$result = array();
}
if (is_object($this->Logger)) {
$this->Logger->log(array('time' => date('Y-m-d H:i:s'), 'duration' => time() - $start, 'method' => $method, 'args' => $args, 'attempts' => $attempts, 'result' => $req->faultCode() ? 'Failed' : count($result) . ' Records Returned', 'error_message' => $req->faultCode() ? $req->faultString() : null));
}
if ($req->faultCode()) {
$exception = new Infusionsoft_Exception($req->faultString() . "\nAttempted: {$attempts} time(s).", $method, $args);
$this->addException($exception);
throw $exception;
return FALSE;
}
if ($attempts > 2) {
CakeLog::write('notice', "Infusionsoft call required {$attempts} calls to receive a successful response. Method: {$method} FaultCode: {$lastAttemptFaultCode} FaultString: {$lastAttemptFaultString}");
}
return $result;
}
开发者ID:s1mple,项目名称:infusionsoft-php-sdk,代码行数:41,代码来源:App.php
示例15: addCamp
function addCamp($CID, $FUS)
{
###Set up global variables###
global $client, $key;
################################################################################
### Note: at the time that the API was written "Campaigns" were actually ###
### Follow up sequences. This is why the action to add a user to a Follow up ###
### sequence is called "addToCampaign". ###
### ###
################################################################################
###Set up the call to add to the Follow up sequence###
$call = new xmlrpcmsg("ContactService.addToCampaign", array(php_xmlrpc_encode($key), php_xmlrpc_encode($CID), php_xmlrpc_encode($FUS)));
###Send the call###
$result = $client->send($call);
if (!$result->faultCode()) {
print "Contact added to Follow up sequence " . $CMP;
print "<BR>";
} else {
print $result->faultCode() . "<BR>";
print $result->faultString() . "<BR>";
}
}
开发者ID:luka-php,项目名称:API-Sample-Code,代码行数:22,代码来源:ContactService-Sample.php
示例16: executeWebServiceRequest
protected static function executeWebServiceRequest($eschool, $func, $params = array())
{
global $CFG;
$result = false;
$server = array();
$params = php_xmlrpc_encode($params);
$wwwroot = $eschool->getAppUrl();
if ($server[$wwwroot] = $eschool->getWebServicesToken()) {
$xmlrpc_client = new xmlrpc_client("{$wwwroot}/webservice/xmlrpc/server.php?wstoken={$server[$wwwroot]}");
$xmlrpc_msg = new xmlrpcmsg($func, array($params));
$xmlrpc_resp = $xmlrpc_client->send($xmlrpc_msg);
if ($xmlrpc_resp == false) {
$CFG->current_app->gcError('GcrWebService call failed: ' . $func);
}
if (!$xmlrpc_resp->faultCode()) {
$result = php_xmlrpc_decode($xmlrpc_resp->value());
}
if (!empty($xmlrpc_resp->errstr)) {
$CFG->current_app->gcError('GcrWebService call error: ' . $xmlrpc_resp->errstr);
}
}
return $result;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:23,代码来源:GcrMdlWebServices.class.php
示例17: array
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$GLOBALS['phpgw_info'] = array();
$GLOBALS['phpgw_info']['flags'] = array('currentapp' => 'xmlrpc', 'noheader' => False, 'noappheader' => False, 'nonavbar' => False);
include '../header.inc.php';
phpgw::import_class('phpgwapi.xmlrpc_client');
if ($_POST['stateno'] != '') {
$username = 'anonymous';
$password = 'anonymous1';
$phpgw_domain = 'default';
$stateno = phpgw::get_var('stateno', 'int', 'POST', 0);
$c = new xmlrpc_client("{$GLOBALS['phpgw_info']['server']['webserver_url']}/xmlrpc.php?domain={$phpgw_domain}", $_SERVER['HTTP_HOST'], 80);
$c->setCredentials($username, $password);
$f = new xmlrpcmsg('xmlrpc.examples.findstate', array(php_xmlrpc_encode($stateno)));
// print "<pre>" . htmlentities($f->serialize('UTF-8')) . "</pre>\n";
// $c->setDebug(1);
$r =& $c->send($f);
// $cookies = $r->cookies();
if (!$r->faultCode()) {
$v = $r->value();
print "</pre><br/>State number " . $stateno . " is " . htmlspecialchars($v->scalarval()) . "<br/>";
// print "<HR>I got this value back<BR><PRE>" .
// htmlentities($r->serialize()). "</PRE><HR>\n";
} else {
print "An error occurred: ";
print "Code: " . htmlspecialchars($r->faultCode()) . " Reason: '" . htmlspecialchars($r->faultString()) . "'</pre><br/>";
}
} else {
$stateno = "";
开发者ID:HaakonME,项目名称:porticoestate,代码行数:31,代码来源:client.php
示例18: php_xmlrpc_encode
/**
* Takes native php types and encodes them into xmlrpc PHP object format.
* It will not re-encode xmlrpcval objects.
*
* Feature creep -- could support more types via optional type argument
* (string => datetime support has been added, ??? => base64 not yet)
*
* If given a proper options parameter, php object instances will be encoded
* into 'special' xmlrpc values, that can later be decoded into php objects
* by calling php_xmlrpc_decode() with a corresponding option
*
* @author Dan Libby ([email protected])
*
* @param mixed $php_val the value to be converted into an xmlrpcval object
* @param array $options can include 'encode_php_objs', 'auto_dates', 'null_extension' or 'extension_api'
* @return xmlrpcval
*/
function php_xmlrpc_encode($php_val, $options = array())
{
$type = gettype($php_val);
switch ($type) {
case 'string':
if (in_array('auto_dates', $options) && preg_match('/^[0-9]{8}T[0-9]{2}:[0-9]{2}:[0-9]{2}$/', $php_val)) {
$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDateTime']);
} else {
$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcString']);
}
break;
case 'integer':
$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcInt']);
break;
case 'double':
$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcDouble']);
break;
// <G_Giunta_2001-02-29>
// Add support for encoding/decoding of booleans, since they are supported in PHP
// <G_Giunta_2001-02-29>
// Add support for encoding/decoding of booleans, since they are supported in PHP
case 'boolean':
$xmlrpc_val = new xmlrpcval($php_val, $GLOBALS['xmlrpcBoolean']);
break;
// </G_Giunta_2001-02-29>
// </G_Giunta_2001-02-29>
case 'array':
// PHP arrays can be encoded to either xmlrpc structs or arrays,
// depending on wheter they are hashes or plain 0..n integer indexed
// A shorter one-liner would be
// $tmp = array_diff(array_keys($php_val), range(0, count($php_val)-1));
// but execution time skyrockets!
$j = 0;
$arr = array();
$ko = false;
foreach ($php_val as $key => $val) {
$arr[$key] = php_xmlrpc_encode($val, $options);
if (!$ko && $key !== $j) {
$ko = true;
}
$j++;
}
if ($ko) {
$xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']);
} else {
$xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcArray']);
}
break;
case 'object':
if (is_a($php_val, 'xmlrpcval')) {
$xmlrpc_val = $php_val;
} else {
if (is_a($php_val, 'DateTime')) {
$xmlrpc_val = new xmlrpcval($php_val->format('Ymd\\TH:i:s'), $GLOBALS['xmlrpcStruct']);
} else {
$arr = array();
reset($php_val);
while (list($k, $v) = each($php_val)) {
$arr[$k] = php_xmlrpc_encode($v, $options);
}
$xmlrpc_val = new xmlrpcval($arr, $GLOBALS['xmlrpcStruct']);
if (in_array('encode_php_objs', $options)) {
// let's save original class name into xmlrpcval:
// might be useful later on...
$xmlrpc_val->_php_class = get_class($php_val);
}
}
}
break;
case 'NULL':
if (in_array('extension_api', $options)) {
$xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcString']);
} else {
if (in_array('null_extension', $options)) {
$xmlrpc_val = new xmlrpcval('', $GLOBALS['xmlrpcNull']);
} else {
$xmlrpc_val = new xmlrpcval();
}
}
break;
case 'resource':
if (in_array('extension_api', $options)) {
$xmlrpc_val = new xmlrpcval((int) $php_val, $GLOBALS['xmlrpcInt']);
//.........这里部分代码省略.........
开发者ID:gggeek,项目名称:ggwebservices,代码行数:101,代码来源:xmlrpc.inc.php
示例19: gettype
/**
* Takes native php types and encodes them into xmlrpc PHP object format.
* It will not re-encode xmlrpcval objects.
* Feature creep -- could support more types via optional type argument
* (string => datetime support has been added, ??? => base64 not yet)
*
* @author Dan Libby ([email protected])
*
* @param mixed $php_val the value to be converted into an xmlrpcval object
* @param array $options can include 'encode_php_objs' and 'auto_dates'
* @return xmlrpcval
*/
function &php_xmlrpc_encode($php_val, $options = '')
{
$type = gettype($php_val);
$xmlrpc_val =& new xmlrpcval();
switch ($type) {
case 'array':
// PHP arrays can be encoded to either xmlrpc structs or arrays,
// depending on wheter they are hashes or plain 0..n integer indexed
// A shorter one-liner would be
// $tmp = array_diff(array_keys($php_val), range(0, count($php_val)-1));
// but execution time skyrockets!
$j = 0;
$arr = array();
$ko = false;
foreach ($php_val as $key => $val) {
$arr[$key] =& php_xmlrpc_encode($val, $options);
if (!$ko && $key !== $j) {
$ko = true;
}
$j++;
}
if ($ko) {
$xmlrpc_val->addStruct($arr);
} else {
$xmlrpc_val->addArray($arr);
}
break;
case 'object':
if (is_a($php_val, 'xmlrpcval')) {
$xmlrpc_val = $php_val;
} else {
$arr = array();
while (list($k, $v) = each($php_val)) {
$arr[$k] = php_xmlrpc_encode($v, $options);
}
$xmlrpc_val->addStruct($arr);
if (@in_array('encode_php_objs', $options)) {
// let's save original class name into xmlrpcval:
// might be useful later on...
$xmlrpc_val->_php_class = get_class($php_val);
}
}
break;
case 'integer':
$xmlrpc_val->addScalar($php_val, $GLOBALS['xmlrpcInt']);
break;
case 'double':
$xmlrpc_val->addScalar($php_val, $GLOBALS['xmlrpcDouble']);
break;
case 'string':
if (@in_array('auto_dates', $options) && ereg("^[0-9]{8}\\T{1}[0-9]{2}\\:[0-9]{2}\\:[0-9]{2}\$", $php_val)) {
$xmlrpc_val->addScalar($php_val, $GLOBALS['xmlrpcDateTime']);
} else {
$xmlrpc_val->addScalar($php_val, $GLOBALS['xmlrpcString']);
}
break;
// <G_Giunta_2001-02-29>
// Add support for encoding/decoding of booleans, since they are supported in PHP
// <G_Giunta_2001-02-29>
// Add support for encoding/decoding of booleans, since they are supported in PHP
case 'boolean':
$xmlrpc_val->addScalar($php_val, $GLOBALS['xmlrpcBoolean']);
break;
// </G_Giunta_2001-02-29>
// catch "resource", "NULL", "user function", "unknown type"
//case 'unknown type':
// </G_Giunta_2001-02-29>
// catch "resource", "NULL", "user function", "unknown type"
//case 'unknown type':
default:
// giancarlo pinerolo <[email protected]>
// it has to return
// an empty object in case (which is already
// at this point), not a boolean.
break;
}
return $xmlrpc_val;
}
开发者ID:pudney,项目名称:hellaphone,代码行数:90,代码来源:xmlrpc.php
示例20: getProductArray
public function getProductArray($product_id)
{
$type = 'product';
$product = Mage::getModel('catalog/product')->load($product_id);
$ean = $product->getEan();
$website_ids = $product->getWebsiteIds();
$product_scope = Mage::getStoreConfig('catalog/price/scope');
$website_ids = php_xmlrpc_encode($website_ids);
$keys = array('simple', 'grouped', 'configurable', 'virtual', 'bundle', 'downloadable');
$product_type = $product->getTypeID();
if (!in_array($product_type, $keys)) {
$product_type = "";
}
if (!in_array($product_type, array('simple', 'configurable'))) {
$type = 'service';
}
$status = true;
$status = urlencode($product->getStatus());
if ($status == '2') {
$status = false;
}
$sku = urlencode($product->getSku());
$xmlrpc_array = array('type' => new xmlrpcval($type, "string"), 'default_code' => new xmlrpcval($sku, "string"), 'mage_id' => new xmlrpcval($product_id, "int"), 'sale_ok' => new xmlrpcval($status, "boolean"));
$xmlrpc_array['wk_websites_id'] = $website_ids;
if ($product_scope) {
$price_list = array();
$stores = Mage::getModel('core/store_api')->items();
foreach ($stores as $store_data) {
$store_id = $store_data['store_id'];
$website_id = $store_data['website']['website_id'];
$product_price = Mage::getModel('catalog/product')->setStoreId($store_id)->load($product_id)->getPrice();
$price_list[$website_id] = $product_price;
}
$price_list = php_xmlrpc_encode($price_list);
$xmlrpc_array['wk_price_list'] = $price_list;
}
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product_id);
if (!$parentIds) {
$set_id = $product->getAttributeSetId();
$name = urlencode($product->getName());
$description = urlencode($product->getDescription());
$short_description = urlencode($product->getShortDescription());
$odoo_category_array = $this->getProductCategoryArray($product->getCategoryIds());
$odoo_set_id = Mage::getModel('magerpsync/attributeset')->getOdooAttributeSetId($set_id);
$xmlrpc_array['name'] = new xmlrpcval($name, "string");
$xmlrpc_array['attribute_set_id'] = new xmlrpcval($odoo_set_id, "int");
$xmlrpc_array['description'] = new xmlrpcval($description, "string");
$xmlrpc_array['description_sale'] = new xmlrpcval($short_description, "string");
$xmlrpc_array['list_price'] = new xmlrpcval($product->getPrice(), "string");
$xmlrpc_array['prod_type'] = new xmlrpcval($product_type, "string");
$xmlrpc_array['category_ids'] = new xmlrpcval($odoo_category_array, "array");
$xmlrpc_array['weight_net'] = new xmlrpcval($product->getWeight(), "double");
}
if ($product->getImage() != 'no_selection') {
try {
$image_path = 'media/catalog/product' . $product->getImage();
$image = file_get_contents($image_path);
} catch (Exception $e) {
$image = false;
}
if ($image) {
$pro_image = base64_encode($image);
$xmlrpc_array['image'] = new xmlrpcval($pro_image, "string");
$xmlrpc_array['image_variant'] = new xmlrpcval($pro_image, "string");
}
}
if ($ean) {
$check_ean = Mage::getModel('magerpsync/commonsocket')->validate_ean13($ean);
if ($check_ean) {
$xmlrpc_array['ean13'] = new xmlrpcval($ean, "string");
}
}
return $xmlrpc_array;
}
开发者ID:babycarenl,项目名称:360,代码行数:74,代码来源:Products.php
注:本文中的php_xmlrpc_encode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论