Hi Matt

I've tried to look into the code for your module and found amplify_get_proper_nouns, but this picks up the whole node, and it's not clear to me if I can use amplify_get_qp for just passing a URL for openamplify to analyse.

So, how can I code a request to openamplify to take a node field as the 'sourceurl', perform its analysis, and then populate another node field with its response?

Am I clutching at straws here?

Any pointers to get me started would be appreciated,

best wishes
scotjam

Comments

mbutcher’s picture

So you want to have the module analyze the contents of a URL? I'd be more than happy to add a function to do that. I've been sitting on a release for a while, too, since the minor bugs I've fixed haven't been enough to justify a full release.

Matt

scotjam’s picture

Submitting a URL to openamplify via your module would be ideal. The output would ideally be populated into another field of the same node that provided the URL to be analysed. Hope I'm not asking for too much here?

If this is easy to do :) then a future feature request would be to allow someone to specify what results to get back and to specify multiple node fields as destinations for the openamplify results.

best wishes
scotjam

scotjam’s picture

Hi Matt

Any further thoughts on how your module might analyse a link field?

I'm interested to here what you think would work best.

best wishes
scotjam

mbutcher’s picture

I added a new function call, amplify_amplify_url($url), that will run the analysis and return a QueryPath object wrapping the results.

There is an example of this in amplify.admin.inc.

So... if you wanted a custom module that read the CCK link field from a node, and then stored the results of the amplification in a CCK textarea, you would do something like this:


// Implementation of hook_nodeapi().
mymod_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {

  if ($op == 'presave'  && $node->type = 'MY_TYPE_NAME') {
    // Grab the URL entered on the node form.
    $url = $node->field_MYLINKFIELDNAME[0]['url'];

    $qp =  amplify_amplify_url($url);

    // Store results in a text area:
    $node->field_MY_AMPLIFY_FIELDNAME[0]['value'] = $qp->xml();
  }
  
}

At that point, you'd have the XML in your database, stored as a CCK field. At any time, you could retrieve it and load it back into QueryPath:

$qp = qp($node->field_MY_AMPLIFY_FIELDNAME[0]['value']);
scotjam’s picture

Hi Matt,

Thanks for this. Trying it out, but occasionally getting error messages of the following sorts...

1. "No suitable nodes are available to serve your request"

and

2. "Could not amplify the document. The remote server did not return the expected data."

Can you kindly clarify what would cause such error messages while requesting amplify to amplify a url and what can be done to fix it?

best wishes
scotjam

scotjam’s picture

An update...

Found this.. titled 'Why is my request failing' on openamplify's site...

http://community.openamplify.com/forums/p/210/281.aspx#281

But no mention of the above two errors which I guess originate from the module.

cheers
scotjam

scotjam’s picture

I've found out that the first error message '"No suitable nodes are available to serve your request"' is from the load balancers as they are timing out waiting for a response, which might explain the second error message 'Could not amplify the document. The remote server did not return the expected data.'

Hope this helps.

best wishes
scotjam

arpieb’s picture

Assigned: Unassigned » arpieb
Status: Active » Fixed

The Could not amplify the document. The remote server did not return the expected data error should be resolved with the updates committed to the 6.x-1.x-dev branch tonight, reported in #988758: No data returned.

Otherwise it looks like the amplify_amplify_url function added by @mbutcher covers the bases for the URL-based OpenAmplify query for this ticket as the other error was network-induced.

Marking as "fixed" for now - if nobody reopens it we should be good to go...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.