0

I am using flag module to have the following user function. So that the followers will be able to read the blog of the users that they followed. Now I want to provide api for mobile application, when a userA go to profile of userB, they can follow userB by follow button. Is there any way to return an api by POST method in RESTfull to do like that?

1 Answer 1

3

Try the following

Flag

URL: http://example.com/apiauthd/flag/flag

Method: POST

Parameters:-
    flag_name: like
    action: flag
    uid: { uid of the logged in user}
    entity_id: { uid of the other user to be flagged}

Unflag

URL: http://example.com/apiauthd/flag/flag

Method: POST

Parameters:-
    flag_name: like
    action: unflag
    uid: { uid of the logged in user}
    entity_id: { uid of the other user to be unflagged}
5
  • Thank you so much! Do you know how to integrate it with hook service resources?
    – Ngo Ho
    Aug 18, 2015 at 5:06
  • You dont have to integrate it with hook service resources for flag service to work.
    – Aparna
    Aug 18, 2015 at 5:09
  • Could you explain more? How can I add api for flagging to endpoint?
    – Ngo Ho
    Aug 18, 2015 at 5:13
  • I think I understand your answer already, thank you for supporting.
    – Ngo Ho
    Aug 18, 2015 at 5:24
  • I'm trying this with Drupal 8 Rest api (/entity/flagging) and nearly there, posting this: { "entity_id":[{"target_id":34}], "flag_id": "my flag type", "uid": [{"target_id": 1 }], "action": "flag" } I get InvalidArgumentException: Field action is unknown. Any thoughts? Just want to set a flag for an entity for one user.
    – bobomoreno
    Oct 14, 2017 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.