I have a rule that fires when saving content with the google translate action to translate the node title and save it into the node body.
0 ms Reacting on event After saving new content.
7.062 ms Evaluating conditions of rule Test Google WS. [edit]
8.141 ms The condition node_is_of_type evaluated to TRUE [edit]
8.16 ms AND evaluated to TRUE.
0 ms Rule Test Google WS fires.
0.456 ms Evaluating the action wsclient_google_translate. [edit]
728.081 ms Added the provided variable result of type wsclient_google_translation_result [edit]
731.566 ms Unable to get the data value for the variable or parameter value. Error: Unable to get the data property translatedText as the parent data structure is not set.
733.463 ms Unable to evaluate action data_set. [edit]
733.559 ms Rule Test Google WS has fired.
741.82 ms Finished reacting on event After saving new content.
Here is my rules export:
{ "rules_test_google_ws" : {
"LABEL" : "Test Google WS",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules", "wsclient" ],
"ON" : [ "node_insert" ],
"IF" : [
{ "node_is_of_type" : { "node" : [ "node" ], "type" : { "value" : { "page" : "page" } } } }
],
"DO" : [
{ "wsclient_google_translate" : {
"USING" : { "param_q" : [ "node:title" ], "param_langpair" : "en|fr" },
"PROVIDE" : { "result" : { "result" : "Translation result" } }
}
},
{ "data_set" : {
"data" : [ "node:body:value" ],
"value" : [ "result:responseData:translatedText" ]
}
}
]
}
}
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | wsclient-added_working_rest_example-1779082.patch | 19.02 KB | othermachines |
Comments
Comment #1
pieterdcSame problem over here
Comment #2
mducharme commentedI'm guessing it's probably a google api change. Any kind of response would have been nice though...
Comment #3
klausiYep, the Google Translate API service does not work anymore, so I disabled it in the wsclient_examples test cases.
We can't do much about that, so I guess we should remove this example.
Examples for other public services would be welcome as replacement!
Comment #3.0
klausiadded code tags
Comment #4
othermachines commentedThe learning curve on this module - which is really quite elegant in its simplicity - is steeper than it needs to be. Since I put in the time already I thought I would put in a bit extra to hopefully make things easier for the next person.
The attached patch does the following:
Removes example code and tests for Google translation service and Twitter search. The latter was referencing the now deprecated Twitter API v.1.
Provides a new, working example of a public REST service: Job Opportunity Announcements (JOA) at USAJOBS.gov. Reliable and simple. API docs here: https://data.usajobs.gov/Rest
Provides two tests for JOA API.
Provides a Rules export to accompany the JOA example. This is disabled by default of course. Since Rules integration is an important part of what sets this module apart the examples seem incomplete without them. By enabling the rule one can immediately see the full extent of the gratification that awaits. :)
Does a bit of code clean-up for consistency and readability.
Note that in wsclient_examples.test I moved code blocks around (to match the hook implementation example) and a couple of things were mislabeled, so a quick scan of the patch might give the impression that the Geocoder.us tests were removed (they weren't).
I hope no one minds that I "unflattened" the arrays in the hook implementation example. I find them much more readable this way.
In a moment I will also be posting an additional patch that provides API documentation for hook_default_wsclient_service(). Because, you know, apparently I just don't know when to stop. :) (Edit - see Issue #2251889: Add API documentation and extend example for hook_default_wsclient_service()).
Looking forward to reviews/feedback!
(Patch is git aware and should be applied with
git amas per docs: https://drupal.org/node/1146430.)