Skip to content

Drupal and REST #15

Closed
Closed

Description

@KCulture

Wanted to know how Drupal setup was going?

Activity

  1. allella commented on Nov 3, 2014

    @allella
    Member

    Nothing yet on the Drupal side.

  2. KCulture commented on Dec 2, 2014

    @KCulture
    Author

    Does the group have an IRC channel or something?

  3. allella commented on Dec 27, 2014

    @allella
    Member

    @smoking-peanuts
    Landon, I'm going to setup a Drupal 8 site and start playing with building a REST API with the organization data.

    It would help if if you want to pick up on what we talked about in late Oct, https://github.com/codeforgreenville/UpstateEvents/wiki/Meeting-Notes-2014.10.28#next-steps and gather keys Evitebrite, Facebook, etc based on which site each organization uses to post their events.

  4. KCulture commented on Dec 31, 2014

    @KCulture
    Author

    Hey

    I am a little confused on how I go about getting key's. 
    Is this the token that will allow us to interact with sever?Are we just looking for the key type?
    Help is appreciated.
    -landon

     On Saturday, December 27, 2014 2:03 PM, Jim Ciallella <[email protected]> wrote:
    

    @smoking-peanuts
    Landon, I'm going to setup a Drupal 8 site and start playing with building a REST API with the organization data.It would help if if you want to pick up on what we talked about in late Oct, https://github.com/codeforgreenville/UpstateEvents/wiki/Meeting-Notes-2014.10.28#next-steps and gather keys Evitebrite, Facebook, etc based on which site each organization uses to post their events.—
    Reply to this email directly or view it on GitHub.

  5. allella commented on Dec 31, 2014

    @allella
    Member

    It depends on where each community posts their events.

    For instance, UpstatePHP uses Eventbrite. So, if you find their organization profile on Eventbrite it has a URL of http://www.eventbrite.com/o/upstatephp-6881540935
    Where the 6881540935 is the organization key that would be needed to search for events belonging to that org.

    There is a new column in the spreadsheet. The immediate goal is to figure out what each organization's key value is and paste it into that column. You can see the real example I just filled out for UpstatePHP. You can start by filling in the other 2 or 3 organizations that have Eventbrite listed in the spreadsheet. Even if they have no active events, or old events like RestFest, you can still get the key.

    Eventbrite's documentation doesn't say where to find the organization ID, but I just figured that's it from experience.

    http://developer.eventbrite.com/doc/organizers/
    and I confirmed it's correct by using the organization ID to get a list of events for UpstatePHP
    http://developer.eventbrite.com/doc/organizers/organizer_list_events/
    like
    http://www.eventbrite.com/rss/organizer_list_events/6881540935

  6. allella commented on Dec 31, 2014

    @allella
    Member

    To determine the Meetup group's ID value you must log into Meetup and then go to their "console" tool for the group lookup functionality.
    https://secure.meetup.com/meetup_api/console/?path=/2/groups

    Then, you need to paste in a community's Meetup.com URL name into the group_urlname text box.

    For example, Code for Greenville's Meetup.com page is http://www.meetup.com/Upstate-Code-for-America/
    so, I pasted
    Upstate-Code-for-America
    into the group_urlname textbox and then hit Enter.

    It will now show a "Response" and in there the first value that says "id" (below utc_offset) is the group_id. That's the value we want to add to our spreadsheet.

    So, in this case, I got
    "id": 14215742,
    so I added 14215742 to the spreadsheet to indicate that is Code for Greenville's group_id

    Meetup.com Group Documentation
    http://www.meetup.com/meetup_api/docs/2/groups/

  7. allella commented on Dec 31, 2014

    @allella
    Member

    @smoking-peanuts We probably won't use RSS, but here are notes on it.
    #16

  8. KCulture commented on Feb 10, 2015

    @KCulture
    Author

    @allella So how is the Rest API going.. anything that I can do to help?

  9. allella commented on Feb 11, 2015

    @allella
    Member

    @smoking-peanuts I got the basic schema setup in Drupal 8. I tried to import all 35 records, but the Feeds module has some bugs.

    I'll see if I can import it in. If not then I may need a hand with data entry.

  10. allella commented on Feb 13, 2015

    @allella
    Member

    @smoking-peanuts The feeds module is "not stable". I'm going to try to create records using the REST API to see how that works.

    https://www.drupal.org/node/2022803

  11. allella commented on Feb 13, 2015

    @allella
    Member

    @smoking-peanuts

    Alright, the REST API is up and working.

    Drupal 8 is still a bit buggy and incomplete, so I spent about 3 hours trying to deal with Drupal 8 instability and 30 minutes to actually configure things and figure how to add an update a record. I actually had to reinstall Drupal, so the work I did last night setting up the Organization fields is gone, but that's only about 5-10 minutes of work.

    Anyway, I was able to create (POST) a test organization with a Name (aka title) and a status (aka field_situation) and then update the title using a (PATCH).

    This means I'll be able to programmatically POST all 35 organizations, so no need to type them in.

    Viewing the Organization

    Again, there's only two fields on the organization at the moment, but I'll add them soon.

    Here's the human readable web page.
    https://data.openupstate.org/node/2

    You'll need to install the Dev HTTP Client plugin for Chrome to see the REST response for the organization. I know that may not make sense, but if you go to the "Using the REST API" section of https://drupalize.me/blog/201401/introduction-restful-web-services-drupal-8 then he has screen shots and it's rather easy.

    Other Notes

    The update command in REST is usually PUT, but Drupal is using PATCH instead because of technical reasons which are way over my head. So, GET, POST, PATCH, DELETE are the 4 commands that correspond to view, add, update, delete.

    It's currently necessary to use Content-Type: application/hal+json for POST and PATCH due to the issues I described here https://www.drupal.org/node/1964034#comment-9619331

  12. allella commented on Feb 13, 2015

    @allella
    Member

    Doing a Simple REST GET Method

    So, once the Postman Client plugin is installed in Google Chrome](https://chrome.google.com/webstore/detail/postman/fhbjgbiflinjbdggehcddcbncdddomop?hl=en) you can just fill in the values shown in the screenshot. However, I'll have to give you the full username and password.

    Request URL
    https://data.openupstate.org/node/7?_format=json
    OR, it's alias
    https://data.openupstate.org/organization/code-for-greenville?_format=json

    Note: Drupal 8 changed things and now requires a _format at the end of GET requests, which is stupid, as using an Accept: header is the better way to do such things for a REST API. Still,
    Accept: application/json

    PHP_AUTH_USER: rest-read-only
    PHP_AUTH_PW: {ask allella and he will share}

    and then just hit "Send".

    Note, this screenshot shows another Chrome Plugin, not Postman, but the general idea is the same.
    rest-api-organization-get-example

    This should yield a 200 OK response, along with a JSON object response with organization and Drupal data, which is the machine parse-able version of the organization data. And, that's the point of this first step of the API.

    1. humans and their web browsers can GET https://data.openupstate.org/node/1 and see an organization web page
    2. machines can add, update, delete, and download organizations through the REST standard by using the same URL https://data.openupstate.org/node/1

    Example of the data from a GET

    {
        "nid": [
            {
                "value": "1"
            }
        ],
        "uuid": [
            {
                "value": "4e6c3292-a8f0-4b6e-a30f-15a0d8589877"
            }
        ],
        "vid": [
            {
                "value": "1"
            }
        ],
        "type": [
            {
                "target_id": "organization"
            }
        ],
        "langcode": [
            {
                "value": "en"
            }
        ],
        "title": [
            {
                "value": "Code For Greenville 2"
            }
        ],
        "uid": [
            {
                "target_id": "2"
            }
        ],
        "status": [
            {
                "value": "1"
            }
        ],
        "created": [
            {
                "value": "1423793426"
            }
        ],
        "changed": [
            {
                "value": "1423806628"
            }
        ],
        "promote": [
            {
                "value": "0"
            }
        ],
        "sticky": [
            {
                "value": "0"
            }
        ],
        "revision_timestamp": [
            {
                "value": "1423793454"
            }
        ],
        "revision_uid": [
            {
                "target_id": "2"
            }
        ],
        "revision_log": [
            {
                "value": ""
            }
        ],
        "path": [
            {
                "alias": null,
                "pid": null
            }
        ],
        "field_situation": [
            {
                "value": "active"
            }
        ]
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions