1+ # Twitter plugin for Phonegap #
2+
3+ This is inspired from the excellent iOS' plugin: https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/Twitter
4+
5+ For the moment, only two (major) functions are binding:
6+ 1. isTwitterAvailable
7+ 2. composeTweet
8+
9+ ## Adding the Plugin to your project ##
10+
11+ Using this plugin requires [Android PhoneGap](http://github.com/phonegap/phonegap-android).
12+
13+ 1. To install the plugin, move www/twitter.js to your project's www folder and include a reference to it in your html file after phonegap.js.
14+
15+ <script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
16+ <script type="text/javascript" charset="utf-8" src="twitter.js"></script>
17+
18+ 2. Create a directory within your project called "src/com/phonegap/plugins/twitter" and move Twitter.java into it.
19+
20+ 3. In your res/xml/plugins.xml file add the following line:
21+
22+ <plugin name="Twitter" value="com.phonegap.plugins.twitter.Twitter"/>
23+
24+ ## Using the plugin ##
25+
26+ The plugin creates the object `window.plugins.twitter`. To use, call one of the following, available methods:
27+
28+ <pre>
29+ /**
30+ * Check if Twitter is installed
31+ *
32+ */
33+ isTwitterAvailable(success, failure)
34+ </pre>
35+
36+ Sample use:
37+
38+ window.plugins.twitter.isTwitterAvailable(
39+ function(bool){
40+ if(bool){
41+ // Do something
42+
43+ } else {
44+ alert("Twitter is not available");
45+ }
46+ },
47+ function(){
48+ alert("We have a problem with the plugin");
49+ }
50+ );
51+
52+ <pre>
53+ /**
54+ * Compose tweet and open the Twitter application
55+ */
56+ composeTweet(success, failure, message) {
57+ </pre>
58+
59+ Sample use:
60+
61+ window.plugins.twitter.composeTweet(
62+ function(){
63+ },
64+ function(){
65+ alert("We have a problem with the plugin");
66+ },
67+ "Base of the tweet"
68+ );
69+
70+
71+ ## LICENSE ##
72+
73+ PhoneGap is available under *either* the terms of the modified BSD license *or* the
74+ MIT License (2008). As a recipient of PhonegGap, you may choose which
75+ license to receive this code under (except as noted in per-module LICENSE
76+ files). Some modules may not be the copyright of Nitobi. These
77+ modules contain explicit declarations of copyright in both the LICENSE files in
78+ the directories in which they reside and in the code itself. No external
79+ contributions are allowed under licenses which are fundamentally incompatible
80+ with the MIT or BSD licenses that PhoneGap is distributed under.
81+
82+ The text of the MIT and BSD licenses is reproduced below.
83+
84+ ---
85+
86+ ### The "New" BSD License
87+
88+ Copyright (c) 2005-2011, Nitobi Software Inc.
89+ All rights reserved.
90+
91+ Redistribution and use in source and binary forms, with or without
92+ modification, are permitted provided that the following conditions are met:
93+
94+ * Redistributions of source code must retain the above copyright notice, this
95+ list of conditions and the following disclaimer.
96+ * Redistributions in binary form must reproduce the above copyright notice,
97+ this list of conditions and the following disclaimer in the documentation
98+ and/or other materials provided with the distribution.
99+ * Neither the name of Phonegap/Nitobi nor the names of its contributors
100+ may be used to endorse or promote products derived from this software
101+ without specific prior written permission.
102+
103+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
104+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
105+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
106+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
107+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
108+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
109+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
110+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
111+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
112+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
113+
114+ ---
115+
116+ ### The MIT License
117+
118+ Copyright (c) <2012> <Objet Direct>
119+
120+ Permission is hereby granted, free of charge, to any person obtaining a copy
121+ of this software and associated documentation files (the "Software"), to deal
122+ in the Software without restriction, including without limitation the rights
123+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
124+ copies of the Software, and to permit persons to whom the Software is
125+ furnished to do so, subject to the following conditions:
126+
127+ The above copyright notice and this permission notice shall be included in
128+ all copies or substantial portions of the Software.
129+
130+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
131+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
132+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
133+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
134+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
135+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
136+ THE SOFTWARE.
137+
0 commit comments