├── LICENSE
├── README.md
├── facebook
├── README.md
├── examples
│ └── FlexExample.mxml
└── images
│ ├── 1.png
│ └── 2.png
├── google
├── README.md
├── examples
│ └── FlexExample.mxml
└── images
│ ├── 1.png
│ └── 2.png
├── instagram
├── README.md
└── examples
│ └── FlexExample.mxml
└── twitter
├── README.md
├── examples
├── FlexExample.mxml
└── isle
│ └── susisu
│ └── twitter
│ ├── Twitter.as
│ ├── TwitterRequest.as
│ ├── TwitterStream.as
│ ├── TwitterStreamStatus.as
│ ├── TwitterTokenSet.as
│ ├── api
│ ├── FALSE.as
│ ├── TRUE.as
│ ├── TwitterURL.as
│ ├── _account_getSettings.as
│ ├── _account_removeProfileBanner.as
│ ├── _account_settings.as
│ ├── _account_updateDeliveryDevice.as
│ ├── _account_updateProfile.as
│ ├── _account_updateProfileBackgroundImage.as
│ ├── _account_updateProfileBanner.as
│ ├── _account_updateProfileColors.as
│ ├── _account_updateProfileImage.as
│ ├── _account_verifyCredentials.as
│ ├── _application_rateLimitStatus.as
│ ├── _blocks_create.as
│ ├── _blocks_destroy.as
│ ├── _blocks_ids.as
│ ├── _blocks_list.as
│ ├── _directMessages.as
│ ├── _directMessages_destroy.as
│ ├── _directMessages_new.as
│ ├── _directMessages_sent.as
│ ├── _directMessages_show.as
│ ├── _favorites_create.as
│ ├── _favorites_destroy.as
│ ├── _favorites_list.as
│ ├── _followers_ids.as
│ ├── _followers_list.as
│ ├── _friends_ids.as
│ ├── _friends_list.as
│ ├── _friendships_create.as
│ ├── _friendships_destroy.as
│ ├── _friendships_incoming.as
│ ├── _friendships_lookup.as
│ ├── _friendships_outgoing.as
│ ├── _friendships_show.as
│ ├── _friendships_update.as
│ ├── _geo_id.as
│ ├── _geo_place.as
│ ├── _geo_reverseGeocode.as
│ ├── _geo_search.as
│ ├── _geo_similarPlaces.as
│ ├── _help_configuration.as
│ ├── _help_languages.as
│ ├── _help_privacy.as
│ ├── _help_tos.as
│ ├── _lists_create.as
│ ├── _lists_destroy.as
│ ├── _lists_list.as
│ ├── _lists_members.as
│ ├── _lists_members_create.as
│ ├── _lists_members_createAll.as
│ ├── _lists_members_destroy.as
│ ├── _lists_members_destroyAll.as
│ ├── _lists_members_show.as
│ ├── _lists_memberships.as
│ ├── _lists_show.as
│ ├── _lists_statuses.as
│ ├── _lists_subscribers.as
│ ├── _lists_subscribers_create.as
│ ├── _lists_subscribers_destroy.as
│ ├── _lists_subscribers_show.as
│ ├── _lists_subscriptions.as
│ ├── _lists_update.as
│ ├── _oauth_accessToken.as
│ ├── _oauth_requestToken.as
│ ├── _savedSearches_create.as
│ ├── _savedSearches_destroy.as
│ ├── _savedSearches_list.as
│ ├── _savedSearches_show.as
│ ├── _search_tweets.as
│ ├── _statuses_destroy.as
│ ├── _statuses_homeTimeline.as
│ ├── _statuses_mentionsTimeline.as
│ ├── _statuses_oembed.as
│ ├── _statuses_retweet.as
│ ├── _statuses_retweets.as
│ ├── _statuses_retweetsOfMe.as
│ ├── _statuses_show.as
│ ├── _statuses_update.as
│ ├── _statuses_updateWithMedia.as
│ ├── _statuses_userTimeline.as
│ ├── _trends_available.as
│ ├── _trends_closest.as
│ ├── _trends_place.as
│ ├── _user.as
│ ├── _users_contributees.as
│ ├── _users_contributors.as
│ ├── _users_lookup.as
│ ├── _users_profileBanner.as
│ ├── _users_reportSpam.as
│ ├── _users_search.as
│ ├── _users_show.as
│ ├── _users_suggestions.as
│ ├── _users_suggestionsSlug.as
│ └── _users_suggestions_members.as
│ ├── events
│ ├── TwitterErrorEvent.as
│ ├── TwitterRequestEvent.as
│ └── TwitterStreamEvent.as
│ └── utils
│ ├── MultipartFormData.as
│ ├── encodeText.as
│ ├── getOAuthParameters.as
│ ├── makeAuthorizationHeader.as
│ ├── makeNonce.as
│ ├── makeOAuthSignature.as
│ ├── mergeObjects.as
│ ├── objectToQueryString.as
│ ├── objectToSortedQueryString.as
│ └── objectToURLRequestHeaders.as
└── images
└── 1.png
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Phantom App Development
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Social Media in Adobe AIR
2 |
3 | This repository contains guides that allow your Adobe AIR applications to interact with social media networks.
4 |
5 | This can be accomplished by just using `StageWebView` and `URLRequest`, this method doesn't require an `ANE`.
6 |
7 | Some examples of what you can achieve are:
8 |
9 | * Send a tweet on behalf the user.
10 | * Allow the user to Like/Share your app.
11 | * Load a user profile information (name, profile picture, email address, friend list).
12 |
13 | ## Getting Started
14 |
15 | Before you start you will require:
16 |
17 | * A valid cellphone number. Registration in the Facebook, Twitter and Google developer portals require a cellphone number where they can confirm your account by SMS.
18 | * The Adobe AIR SDK, preferably a recent version.
19 | * The [AS3 Crypto](http://crypto.hurlant.com/demo/as3crypto.swc) library.
20 |
21 | These guides are compatible with the Apache Flex SDK, Starling Framework and pure AS3 in both Desktop and Mobile projects. The examples are provided for all 3 frameworks and are designed to be easily copied and pasted. You can access these examples with their respective guides by browsing this repository.
22 |
23 | These guides do not work in Flash Player projects because it doesn't support the StageWebView API. If you wish to integrate social media in your Flash Player project you can do it by using their JavaScript libraries and using the `ExternalInterface` API.
24 |
25 | ## Introduction to OAuth
26 |
27 | The OAuth protocol allows third party applications to interact securely with private resources without exposing the logged user credentials.
28 |
29 | The standard workflow is as follows:
30 |
31 | 1. The user wants to access some feature in your app that require a log-in.
32 |
33 | 2. The user is presented with a Sign-In button and presses it.
34 |
35 | 3. A modal window appears (Pop-Up) with a web browser inside (StageWebView) where the user must enter their username and password and allow the permissions the app requested.
36 |
37 | 4. Once the user has successfully logged in, the web browser will be redirected to a 'Success' page that will contain a token/code.
38 |
39 | 5. The app will need to grab said code and perform an `URLRequest` to the OAuth server where the code will be exchanged for an Access Token.
40 |
41 | 6. Once the app has gotten the Access Token, it will be used to interact with private resources, such as fetching friends lists, users profiles and more.
42 |
43 | This workflow varies a bit on each social network, the differences will be outlined in their respective guides.
44 | Each social network guide is separated into their own folder, feel free to read them in any order.
45 |
46 | ## Glossary
47 |
48 | Name | Description
49 | ---|---
50 | ``StageWebView`` | An Adobe AIR component that allows applications to show an embedded web browser.
51 | ``URLRequest`` | An ActionScript 3 class for creating and sending requests to external resources, such as web servers.
52 | ``App ID`` | A string unique to your application that identifies it to the OAuth server. Used as a parameter in a Request Token.
53 | ``Scope`` | A parameter in a Request Token that contains the permissions the app requires.
54 | ``Redirect URI/URL`` | A location where the StageWebView will be redirected upon a successful authorization. This location will contain a code/token that will be retrieved for creating a Token Request.
55 | ``OOB`` | Out-of-bounds, a special OAuth parameter that indicates that a PIN-less authorization is requested.
56 | ``Request Token`` | A string containing several parameters which will be exchanged for an Access Token.
57 | ``Access Token`` | An alphanumeric string that is used as a parameter in URLRequests to access private resources.
58 |
59 | ## Donations
60 |
61 | Feel free to support the development of free guides and examples. Your donations are greatly appreciated.
62 |
63 | [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MQPLL355ZAKXW)
64 |
--------------------------------------------------------------------------------
/facebook/README.md:
--------------------------------------------------------------------------------
1 | # Facebook
2 |
3 | **ATTENTION: THIS GUIDE DOESN't WORK IN MOBILE DEVICES, PLEASE USE THE [FIREBASE FACEBOOK AUTH GUIDE](https://github.com/PhantomAppDevelopment/firebase-as3/tree/master/auth/facebook) INSTEAD**
4 |
5 | Integrating Facebook API functionality in your application doesn't require external libraries.
6 |
7 | ## Getting Started
8 |
9 | 1. Register in the [Facebook Developer portal](https://developers.facebook.com/). You may be asked to provide a valid cell phone number to complete your registration.
10 |
11 | 2. Once registered, locate a drop-down list in the top right and click on it. At the middle it will be an option to `Add a New App`.
12 |
13 | 3. You will be presented with 4 options, select `Website` (even if you are developing an Android or iOS app). We can later add the other platforms when we are ready for deployment.
14 |
15 | 4. Click the button that says `Skip and Create App ID`. A form will appear where you have to provide your app details, once finished click the `Create App ID` button.
16 |
17 | 
18 |
19 | 5. You will be redirected to your Dashboard, click the Get Started button next to the Facebook Login option.
20 |
21 | 6. You will be asked to `Choose a Platform`. Select `Other`.
22 |
23 | 7. Configure the OAuth settings similar to the next image. Set the redirect URI to: `https://www.facebook.com/connect/login_success.html` and press the Save Changes button.
24 |
25 |
26 | 
27 |
28 | 8. Click Settings in the left side menu. You will be presented with a screen with your `App ID` and `App Secret`, you will be required to provide your Facebook password to see the `App Secret`.
29 | 9. Once authorized, copy down your `App ID` and `App Secret`. We are going to use them in a later step.
30 |
31 | At this point the Facebook API will only work with your own Facebook Account, in order for it to work on any account you need to switch your app status from `development` to `public`.
32 |
33 | 8. If you are still in the `Dashboard` click the `App Review` option in the left side.
34 |
35 | 9. In the `Make [Your App Name] public?` section turn it to `Yes`. A pop-up will appear asking if you want to make your app public, click the `Confirm` button.
36 |
37 | With these settings your app will only be allowed to do basic reading operations with the Facebook API. If you want to do writing operations such as `Liking` and `Posting` to the user wall you must submit your app for review.
38 |
39 | ## Implementation
40 |
41 | Open or create a new project.
42 |
43 | Open the file where you want to implement the Sign-In feature.
44 |
45 | Add the following constants and variables:
46 |
47 | ```actionscript
48 | private static const CLIENT_ID:String = "Your own Client ID";
49 | private static const CLIENT_SECRET:String = "Your own Client Secret";
50 |
51 | private var webView:StageWebView;
52 | private var code:String;
53 | private var access_token:String;
54 | private var accessTokenLoader:URLLoader;
55 | private var profileLoader:URLLoader;
56 | ```
57 | Add a button and assign an `EventListener` to it when it gets pressed. The code of the EventListener should be as follows:
58 |
59 | ```actionscript
60 | private function initSignIn():void
61 | {
62 | webView = new StageWebView(true);
63 | webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE, changeLocation);
64 | webView.stage = this.stage;
65 | webView.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
66 | webView.loadURL("https://www.facebook.com/dialog/oauth?client_id="+CLIENT_ID+"&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=email");
67 | }
68 | ```
69 |
70 | We initialized a `StageWebView` instance, set its dimensions to match the stage size. We crafted a special URL that contains several parameters:
71 |
72 | * scope: The permissions we require from the OAuth server, in this case we require the user email address.
73 |
74 | * redirect_uri: We provided a special url from Facebook which will contain the response `code`.
75 |
76 | * client_id: Your Client ID.
77 |
78 | ```actionscript
79 | private function changeLocation(event:LocationChangeEvent):void
80 | {
81 | var location:String = webView.location;
82 |
83 | if(location.indexOf("code=") != -1 && location.indexOf("error") == -1){
84 | webView.dispose();
85 | code = location.substr(location.indexOf("code=")+5, location.length);
86 | getAccessToken();
87 | }
88 | }
89 | ```
90 |
91 | We start listening for a `LocationChange` event (every time the web browser changes its web page), once a web page contains the `code` parameter in its URL we dispose the StageWebView and extract the parameter to a variable.
92 |
93 | Then we called a custom function `getAccessToken()` where we are going to create an `URLRequest` to exchange the `code` for an `access_token`.
94 |
95 | ```actionscript
96 | private function getAccessToken():void
97 | {
98 | var request:URLRequest = new URLRequest("https://graph.facebook.com/v2.3/oauth/access_token?client_id="+CLIENT_ID+"&redirect_uri=https://www.facebook.com/connect/login_success.html&client_secret="+CLIENT_SECRET+"&code="+code);
99 |
100 | accessTokenLoader = new URLLoader();
101 | accessTokenLoader.addEventListener(Event.COMPLETE, accessTokenReceived);
102 | accessTokenLoader.load(request);
103 | }
104 | ```
105 |
106 | We sent all the parameters in a `GET` request and added an `EventListener` which will contain the `access_token`.
107 |
108 | ```actionscript
109 | private function accessTokenReceived(event:Event):void
110 | {
111 | var rawData:Object = JSON.parse(String(event.currentTarget.data));
112 | access_token = rawData.access_token;
113 |
114 | loadProfileInfo();
115 | }
116 | ```
117 |
118 | We converted the response from the `URLRequest` into a `JSON` object and took the `access_token` value and set it into a String.
119 |
120 | With the `access_token` we can connect to the [Facebook Graph API](https://developers.facebook.com/docs/graph-api) very easily, for example we are going to load the logged-in user profile information.
121 |
122 |
123 | ```actionscript
124 | private function loadProfileInfo():void
125 | {
126 | profileLoader = new URLLoader();
127 | profileLoader.addEventListener(Event.COMPLETE, profileLoaded);
128 | profileLoader.load(new URLRequest("https://graph.facebook.com/me/?access_token="+access_token+"&fields=name,email,picture.type(large)"));
129 | }
130 |
131 | private function profileLoaded(event:Event):void
132 | {
133 | trace(event.currentTarget.data);
134 | }
135 | ```
136 |
137 | Note that we needed to specify which fields we need from the API, in this case we asked for the user `name`, `email` and `picture`.
--------------------------------------------------------------------------------
/facebook/examples/FlexExample.mxml:
--------------------------------------------------------------------------------
1 |
2 |