I am uploading a stand-alone module (votingapi_service) that provides Services support for the Voting API. This allows external applications to access and modify Voting API data for Drupal objects. For example, a Flash application could implement an interface for voting on nodes.
votingapi_service provides the following methods, which are primarily wrappers to the corresponding Voting API function:
-- setVote: set vote for specified content from a given user
-- unsetVote: remove vote for specified content from a given user
-- getUserVotes: get all votes for specified content from a given user
-- getContentVotes: get all votes for specified content
-- getVotingResults: get results (current average) for specified content
votingapi_service allows only users with permissions of 'access votes' or of 'edit votes' to use these methods.
The Services community prefers packaging services support for non-core modules with the module, rather than including it with Services. Is there interest to include this with future releases of Voting API?
Comment | File | Size | Author |
---|---|---|---|
#32 | votingapi_service.tgz | 1.94 KB | hawkeye.twolf |
#14 | votingapi_service.zip | 2.11 KB | gbernier |
#12 | votingapi_service.zip | 2.26 KB | RasputinJones |
votingapi_service-20080401.tar_.gz | 1.22 KB | arithmetric |
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedNice work! I just tested this since I was so excited. No issues at all. THis is RTBC, though it would be nice if you fixed the minor issues below.
Some notes:
- i don't think we usually want license info in the README and .module files. Everything in the drupal.org repository is already GPL v2. See the top level license file. i would also remove the version info. the $Id automatically tracks that.
- 'package = Voting' is more consistent with votingapi itself and fivestar
- code looks small and clean. nice.
Minor: Maintainers generally prefer that you upload 3 attachments instead of one tarball. easier to click on and review within a browser. we also often have scripts that apply patches from URLs and those don't expect (gzipped) tarballs.
Comment #2
youngbuddha CreditAttribution: youngbuddha commentedHi,
I am looking for exactly the same functionality, being able to change the ratings of a node using HTTP based method invocation. That way, remote clients can be given a URL for solely the voting submission.
I would really love to see this added to the default Voting API module as a standard feature!
Thanks,
Comment #3
eaton CreditAttribution: eaton commentedThis is unlikely to be added as part of VotingAPI module proper, but perhaps it can be rolled in as a secondary module included in the download. Would it make more sense, though, to included it in Services.module?
Comment #4
mitchell CreditAttribution: mitchell commentedVery cool issue!
@detour: Could you please port you patch?
@Eaton: After talking to the services module maintainers, they are only willing to include core and views related services. On the other hand, quicksketch indicated he's open to putting services integration in Flag, as per #182071: Expose Flag Service.
Comment #5
mitchell CreditAttribution: mitchell commentedMarked #182073: Expose Vote up Down Methods via Services as a duplicate of this issue.
Comment #6
cangeceiro CreditAttribution: cangeceiro commentedit may be worth noting, this module is not compatible with drupal 6.11
Comment #7
eaton CreditAttribution: eaton commentedYeah, I've taken a look and it appears to be a Drupal 5 module. I'd like to get it in for the upcoming 'final' release of VAPI 2, but I think i'll need to take another crack at it.
Comment #8
miruoss CreditAttribution: miruoss commentedHi there
Im very interested in this feature. If there is no way this is included to the VotingAPI module, it would be great to have it as a separate drupal module. Detour, are you gonna make a module out of this?
Cheers,
Michael
Comment #9
lesleyfernandes CreditAttribution: lesleyfernandes commentedIs this working for Drupal 6.15 and Services 2.0? Thanks
Comment #10
beauz CreditAttribution: beauz commentedAlso wondering if this is working properly for drupal 6.16 and services 2.0
Thanks
Comment #11
Cyberwolf CreditAttribution: Cyberwolf commentedSubscribing.
Comment #12
RasputinJones CreditAttribution: RasputinJones commentedHacked this together for Drupal 6. This is not fully tested but should work with services 2.0. Derived most of the code from fivestar's api I kept the original posters API. Feedback is welcome.
Comment #13
gbernier CreditAttribution: gbernier commentedHey Rasputin,
I was looking for this solution as well, if I have any feedback I will provide it to you. Just installing now.
Cheers,
Gene Bernier
Comment #14
gbernier CreditAttribution: gbernier commentedHey Rasputin and all,
Found one issue with the service on the votingapi.getContentVotes, it's only returning one result. The issue is on line 243, the code is returning $votes[0] instead of $votes. Aside from that I've had no issues with this, great module you should post it as a contribute, if you do let me know and I'd love to write a recommendation on drupalmodules.com for it.
Attached is the changed module
Comment #15
gbernier CreditAttribution: gbernier commentedOne further follow up, some people may want to make the same change on line 257 so you can get the full array back from getVotingResults, the element [0] provides the average value of all the votes cast and [1] returns how many votes have been casted.
Cheers,
Gene Bernier
Comment #16
RasputinJones CreditAttribution: RasputinJones commentedThanks. I'll see if i can post some updates today. How do you set up a contribute?
Comment #17
gunslinger4hire CreditAttribution: gunslinger4hire commentedAlways when i try to call the votingapi services functions i get an Access denied error. If i try it with the services admin page or with remote calls with amfphp... All the rights are properly configured... Any ideas where could be my fault or the error?
Comment #18
lesleyfernandes CreditAttribution: lesleyfernandes commentedpermissions?
Comment #19
gunslinger4hire CreditAttribution: gunslinger4hire commentednope, unfortunately not... on my develop machine i granted all roles all permissions, even when i delete the permissions in the source code of the voting api service module, it wont work.
i suspect the voting api module itself right now... but without a hint whre to look...
Comment #20
sphism CreditAttribution: sphism commented^^^ you might need to set access on the service key, in drupal 6 they are here > admin/build/services/keys
Comment #21
Mac_Weber CreditAttribution: Mac_Weber commentedAnything for services 3?
Comment #22
dereckd CreditAttribution: dereckd commentedReally need something like this for services 3, as well
Comment #23
mwsam CreditAttribution: mwsam commentedI have take the code from here and made a D7 version module out of it, which is compatible with services 3.x. The project page is here http://drupal.org/sandbox/mwsam/1427714.
Comment #24
dereckd CreditAttribution: dereckd commentedThanks for your work! @mwsam when I check out the repo I'm informed that it's empty tried via smart git and command line
Comment #25
mwsam CreditAttribution: mwsam commentedFrom this page http://drupal.org/project/1427714/git-instructions you can check out 7.x-1.x branch using this instruction:
git clone --branch 7.x-1.x mwsam@git.drupal.org:sandbox/mwsam/1427714.git voting_api_services
Or alternatively you can also download the latest snapshot from here http://drupalcode.org/sandbox/mwsam/1427714.git/shortlog/refs/heads/7.x-1.x
Comment #26
galis007 CreditAttribution: galis007 commentedIs it possible to get the services 3 version backported for drupal 6 also ive been trying to figure out an example of the url to set a vote eg http://.....endpoint/votingapi/setvote/?
Comment #27
mwsam CreditAttribution: mwsam commentedIt is possible to backport into 6.x. I started the services 2.x to 3.x upgrade for 7.x branch out of a bounty posted in paid services forum, but I haven't received any payment and have since hear nothing from the bounty issuer despite several contact attempts. So somebody may needs to take it from here.
Comment #28
bhavin.ahya CreditAttribution: bhavin.ahya commentedI just created a module to support voting api with services 3.x in drupal 6.x and it's working fine. It will be great if someone can help me to post this module.
Comment #29
tpainton CreditAttribution: tpainton commentedAwesome.. Will give it a shot. Found it http://git.drupal.org/sandbox/mwsam/1427714.git voting_api_services
Comment #30
dereckd CreditAttribution: dereckd commentedhow would one format a REST request for the voting API
Comment #31
tpainton CreditAttribution: tpainton commentedThe module creates voting actions. Simply direct to endpoint and action votingapi/setVote to set a vote then supply the correct JSON as required by the module. I don't have PHP to show as example, as I am using Android Java to do the task. The way you figure out how to craft the JSON is by looking at the modules votingapi_service_services_resources method..
The name of each args element is the key for each JSON value.. so the above setVote JSON would look like..
{"content_id":"232", "vote":"4", "content_type":"song", "tag":"dance"}
So one would direct then connection to www.mysite.com/votingapi/setvote and then post the JSON as above to vote 4 stars for Node 232 that is a Song content type under the voting criteria (tag) of dance. The other options you have can be found in the same way by looking at the rest of the code.
Comment #32
hawkeye.twolfDrupal 6.x Services 3.x version attached. A few notes re:changes from the 7.x version
Comment #33
legolasboDrupal 6 is no longer supported. Closing old issues to clean up the issue queue.
Please reopen and update this issue if this is still an issue in the D7 or D8 version.