Does anyone know how this code is not going to work anymore, or why all my services 2 methods come back invalid?
//presume correct api_key, nonce etc
$hash = hash_hmac('sha256', $timestamp .';mysite.com;'. $nonce .';'.'vote.setVote', $api_key, 0);

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, 'http://mysite.com/services/json');

//prepare the field values being posted to the service
$data = array(
'method' => 'vote.setVote',
'hash' => $hash,
'domain_name' => 'mysite.com',
'time_stamp' => $timestamp,
'domain_time_stamp' => $timestamp,
'nonce' => $nonce,
'api_key' => $api_key,
'sessid' => $sessid,
'content_type' => 'node',
'content_id' => $myNID,
'vote_value'=> $voteVal,
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);

This was working under services version 0.15. With services 2 dev I get error true, invalid method vote.setVote
I also get invalid method for any other method I try to run. I get invalid if I turn off authentication.
I'd revert to services 0.15 but what i really need now is to use node.save, and I can't get that working under 0.15, so I'm trying to get services 2 going...

Comments

gdd’s picture

The authentication changed between the two versions, and it appears that the upgrade path isn't working quite properly. First make sure you ran update.php after upgrading. In the new version of services, authentication is its own module. So you should go to admin/build/modules, look for the Services - Authentication group, turn on Key Authentication, and save the modules form. Now you can go to the Services settings and make sure your keys are still there.

I'll take a look at the upgrade path and see what we can do about making it cleaner.

ransomweaver’s picture

Yes, I saw that there was a new key auth module to activate, but I activated that with no improvement.
Other things I did: uninstalled services competely, deleted module/services entries in system table, cleared out caches,
then I made a completely virgin drupal install, with json_server and services 2dev:
no authentication, anon given load node data perms, made a page node, tried node.view in the services browser, it returned the node.
then here is my test remote service call:
ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, 'http://mysite.com/drupaltest/services/json');

$data = array(
'method' => 'node.view',
'nid' => 1,
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$result = curl_exec($ch);
return $result;

I get back: { "#error": true, "#data": "Invalid method node.view" }

Now the fact is that this php is running on the same server, but a different domain as the drupal service; don't know if that might be a factor.

Thanks

gdd’s picture

Another thing you want to check is that you have the Node Service module enabled, that would cause Services to return the error you are reporting (note this is the Node Services module not the Node Resource module.)

If this is already taken care of I can look into this later, I need to update the handbooks anyways.

ransomweaver’s picture

Correct, in my drupal virgin install node service is activated, shows node.get, node.view, node.save, node.delete in the services broswer, where pasting {"type":"page","title":"test"} in the node field for node.save creates a new node, but I can't get any love from my remote methods.

ransomweaver’s picture

Is necessary to call system.connect before trying to access any of the other methods?

ransomweaver’s picture

using php cURL to try system.connect via json_server I get { "#error": true, "#data": "Invalid method system.connect" }
however using amfphp from flash I succeed with system.connect, and indeed I seem to be able to use all the services. This doesn't help my original vote.setVote problem though; I still need to use serverside php there. Maybe the problem is the json_server?

gdd’s picture

Title: All methods coming back invalid » SON Server returns "invalid method" for all function calls with Services 6.x-2.x-dev
Status: Active » Closed (won't fix)

OK so it turns out that there was a change to Services some months back that is causing JSON Server to fail. I have a posted a patch on your issue in the JSON Server queue and am closing this issue. Follow up over there.

#663744: JSON Server returns "invalid method" for all function calls with Services 6.x-2.x-dev

gdd’s picture

Title: SON Server returns "invalid method" for all function calls with Services 6.x-2.x-dev » JSON Server returns "invalid method" for all function calls with Services 6.x-2.x-dev