We are using Drupal 7 and the Services API connecting to our iOS and Android APPs. The purpose of the APP is to record video and upload the YouTube link to the website. Both APPs are currently able to authenticate the user and create a node with the parameters of type, title, and body. The problem is two-fold:

1. How do we create a node with file field using the Media and Media:YouTube modules
2. How do we create a node with entity reference fields using widgets such as OG Reference, Select and Autocomplete

For example, we have content type called Clip. The clip content type has the following fields:

Title
Body
YouTube Link (File) Using the Media and Media:YouTube Modules
Clip Type (Term Reference - Select Widget)
Group Audience (Entity Reference - OG Reference)
Genre (Term Reference - Autocomplete Widget)
Photo (Image)

Important note: This works fine via the website. The issue is currently the user must goto YouTube copy the share URL and place it in the node on the website. This is a bad user experience because the user is required to do multiple steps using both our website and YouTube. To simplify the user experience the APP will bridge the gap by capturing the video, upload the video to YouTube, take the URL link from YouTube, create the node on the website with all the fields listed above. The APP currently captures the video, uploads the video to YouTube, takes the URL link from YouTube. The missing component is creating the node with the YouTube link, Clip type, Group audience, Genre and Photo.

What are the Services API parameters/definitions for each field? The purpose is for the native APP to create the node on the website. When creating the node the lookups for Clip Type, Group Audience and Genre should auto populate on the native APP allowing the user to select the correct value. In addition the APP needs to create the file and add the YouTube link.

Thanks.

Comments

Jaypan’s picture

We just submitted an app to the app store with Services as the back end, so I have some knowledge on this, however we used custom entities, not nodes, so I'm not sure about the specifics of nodes. But, I think you could potentially use the existing Node methods (that come with the services module) to create the node, and the File method (that also comes with the module) to create the node.

Either that or you could create your own custom method, using hook_services_resources(), and in that function, you can programmatically create a node (there is various documentation out there on how to do this).

Note that any files that are uploaded need to be base64 encoded before uploading.

promardi’s picture

Jaypan,

Thanks for getting back to me. The purpose of the APP is to simplify the user experience using the phone vs using the desktop. This is for a video sports site. The primary function of the APP is to record video, trim the video, upload the video to youtube, create the node with the youtube link and other associated fields. All of this process is currently working except for the "create the node with the youtube link and other associated fields. After the video is recorded and uploaded to the users youtube account, there can be up to six content types to select from based on the logged in users roles.

We tested the Services API with Rest Console using the following JSON and it worked fine. We just do not know how to implement with the native APP. The current developer for the native APP does not know Drupal and is having a learning curve working with the Services API.

Below is the JSON we used to test working with entity reference fields and it worked fine:

For entity_reference field with select widget:
{"type":"film","title":"XXXABC222",
"og_group_ref":{"und":[227]}
,"field_youtube":{"und":[{"value":"https://youtu.be/w4vYTBzWXkg"}]}}

For entity reference field with autocomplete widget:
{"type":"film","title":"XXXABC222",
"og_group_ref": [
      {
         "und":{
            "target_id":"227"
         }
      }
   ]
,"field_youtube":{"und":[{"value":"https://youtu.be/w4vYTBzWXkg"}]}}

Below are the six content types and fields:

Field Label, Field Name, Field Type, Widget

Clip:
Title, title
Date, field_date, date, pop-up calendar
YouTube Link, field_youtube, text, text field
Add Clip to Your Highlights, field_highlight, boolean, single on/off checkbox
Sport, field_select_sport, term reference, select list
Level, field_select_level, term reference, select list
Age, field_select_age, term reference, select list
Videographer, field_select_videographer, entity reference, autocomplete

Film:
Title, title
YouTube Link, field_youtube, text, text field
Date, field_date, date, pop-up calendar
Period, field_period, list (integer), select list
Description, body, long text and summary, text area with a summary
Film Type, field_film_type, term reference, select list
Team Opponent, field_select_team_opponent, entity reference, autocomplete
Athlete Opponent, field_select_athlete_opponent, entity reference, autocomplete
Groups audience, og_group_ref, entity reference, check boxes/radio buttons

Game:
Title, title
Date, field_date, date, pop-up calendar
YouTube Link, field_youtube, text, text field
Add Clip to Your Highlights, field_highlight, boolean, single on/off checkbox
Sport, field_select_sport, term reference, select list
Level, field_select_level, term reference, select list
Age, field_select_age, term reference, select list
Home Team, field_select_home_team, entity reference, autocomplete
Away Team, field_select_away_team, entity reference, autocomplete
Videographer, field_select_videographer, entity reference, autocomplete

Play:
Title, title
YouTube Link, field_youtube, text, text field
Groups audience, og_group_ref, entity reference, check boxes/radio buttons
Description, body, long text and summary, text area with a summary
Play Type, field_play_type, term reference, clientside hierarchical select
Positions, field_select_positions, term reference, clientside hierarchical select

Practice:
Title, title
YouTube Link, field_youtube, text, text field
Date, field_date, date, pop-up calendar
Description, body, long text and summary, text area with a summary
Type, field_select_type_practice, term reference, select list
Groups audience, og_group_ref, entity reference, check boxes/radio buttons

Workout:
Title, title
YouTube Link, field_youtube, text, text field
Date, field_date, date, pop-up calendar
Description, body, long text and summary, text area with a summary
Workout Type, field_workout_type, term reference, select list
Groups audience, og_group_ref, entity reference, check boxes/radio buttons

Can you complete this project and what is your cost and timeframe? Thanks

Jaypan’s picture

Services doesn't care where the request comes from, so if you can get it to work outside the app, you just have to send that same JSON from the app.

I'm sorry, we're booked solid for at least 4 months right now, likely longer. I may hire another developer to help us with some of our overflow, but we're still looking at a few months away even then.

promardi’s picture

Jaypan,

If you could refer us to someone else you feel can help would be appreciated.

Thanks.