Hi,

I'm trying to make very simple service, which will return drupals internal url for the node.
but I can't figure out how to access to the result which is returned from the service.
Service working properly, I can see that from the netdebugger. And with help of service browser I can see that I'm getting: Result /mysite/12

Service code:

/**
 * Implementation of hook_service().
 */

function utils_service_service() {
  return array(
	array(
      '#method'   => 'utils.getNodeLink',
      '#callback' => 'utils_service_get_node_link',
      '#args'     => array(
        array(
          '#name'         => 'node_id',
          '#type'         => 'int',
          '#description'  => t('Node id.'),
        ),
      ),
      '#return'   => 'string',
      '#help'     => t('Returns link to the specific node.')
    ),
  );
}


/**
 * get url
 */
function utils_service_get_node_link($node_id) { 
  return url($node_id);
}

AS Code:

import mx.remoting.*;
import mx.rpc.*;
import mx.remoting.debug.NetDebug;
import mx.utils.Delegate;
var gatewayUrl:String = "http://localhost/mysite/services/amfphp";
NetDebug.initialize();

var tf:TextField = this.createTextField("status", 10, 0, 0, 2000, 2000);
tf.multiline = true;
tf.html = true;

var views:Service = new Service(gatewayUrl, null, 'views', null, null);
var pc:PendingCall = views.getView('promoted', ['nid', 'uid', 'name', 'title', 'field_pictures', 'field_price']);
pc.responder = new RelayResponder(this, "handleGetPromoted", "handleError");

var utils:Service = new Service(gatewayUrl, null, 'utils', null, null);

function function_that_will_print_service_value(nid:Number)
{
	var pc:PendingCall = utils.getNodeLink(nid);
	pc.responder = new RelayResponder(this, "handleGetLink");

	MAGICK_STATEMENT_WHICH_WILL_RETURN_VALUE = re.result;

	return MAGICK_STATEMENT_WHICH_WILL_RETURN_VALUE;
}

function handleGetLink(re:ResultEvent)
{
	trace("handleGetLink: " + re.result);
}


function handleGetPromoted(re:ResultEvent)
{
	var rs:Object = re.result;
	var nCount = rs.length;
	for (i=0; i<nCount; i++)
	{
		tf.htmlText += rs[i].nid + "<br/>";
		tf.htmlText += rs[i].title + "<br/>";
		tf.htmlText += rs[i].userid + "<br/>";
		tf.htmlText += rs[i].name + "<br/>";
		tf.htmlText += rs[i].field_price[0].value + "<br/>";
		tf.htmlText += rs[i].field_pictures[0].filepath + "<br/><br/>";

                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		tf.htmlText += function_that_will_print_service_value(rs[i].nid) + "<br/><br/>";
                //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	}
}

Please help me...

Comments

marcingy’s picture

Status: Active » Closed (fixed)