This sample code shows how to modify Facebook's Scrumptious Sample App to use Kinvey to host Open Graph Objects and post actions to a user's timeline. Kinvey dynamically generates the Open Graph object html based upon the information chosen by the user.
Scrumptious users post that they "ate" a meal, allowing them to tag where, when, and with whom they ate the meal, and attach a picture of the meal.
The sample repository comes with the Kinvey Android Client and Fracebook frameworks that it was developed against. In production code, you should update to the latest versions of these libraries.
- Create your Scrumptious App on Facebook.
- Set up the "eat" action and "meal" object.
- App namespace is
kinvey_scrumptious
.
- Create a new App on Kinvey.
-
Create a "Eating" collection to store the data for each meal uploaded by the users.
-
Set up mappings in the "Data Links" -> "Facebook Open Graph" settings. Follow the steps in this tutorial set up the mappings between the Kinvey object and the Facebook object.
- You'll need to paste the "get code" for the meal object. This will set up some of the fields and settings for a
kinvey_scrumptious:meal
object type. - Map the following fields:
og:title
->selectedMeal
og:image
->imageURL
place:location:latitude
->latitude
place:location:longitude
->longitude
- You will need to add additional mappings for these fields:
og:determiner
->determiner
- You'll need to paste the "get code" for the meal object. This will set up some of the fields and settings for a
-
Add a new action
kinvey_scrumptious:eat
to represent the eat action.
-
- In
assets/kinvey.properties
enter your Kinvey app App ID and App Secret. - In
res\strings.xml
, enter your Facebook App ID in theapp_id
value.
- Created MealEntity object to represent the OG meal object. This is used to store the meal's information in the Kinvey backend.
- MealEntity objects are populated with data chosen by the user in the interface, and then uploaded to Kinvey in three separate steps:
- Upload the image to Kinvey.
- Upload the data to Kinvey.
- Tell Kinvey to post the
eat
action to the user's timeline.
- Added ability to take a picture of the meal.
- Added additional OG fields, such as
determiner
, to improve the user experience.
- To add new meal types, just add the name to the
food_types
array created inres\strings.xml
. You will also need to add a determiner to thefood_determiners
array at the same index. The determiner is the English indefinite article that corresponds to the meal name. This is used to make the OG action read like a normal sentence. For example "Bob ate a Hotdog", "Jill ate an Escargot", "Roger ate Mexican". - To add new fields, add a property to the
MealEntity
and map that property to the backend by preceding the variable declaration with a@Key
annotation. Then in theFBOG
collection on the backend, map the field name to the Facebook Open Graph object field name.
Website: www.kinvey.com
Support: [email protected]
##License
Copyright (c) 2014 Kinvey Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.