Skip to content
Newer
Older
100644 188 lines (123 sloc) 6.28 KB
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
1 Yahoo! Social SDK - PHP5
8de7b17 @dustinwhittle updated README with alpha/experimental note
dustinwhittle authored Oct 8, 2009
2 ========================
3
4 **Warning**
5 =======
6
7 **_The yos-social-php5 SDK is released alpha and is experimental. The difference between the yos-social-php5 sdk and the yos-social-php sdk is that the storage is left for the user to implement.
8 The new implementation is more flexible as developers can store the OAuth tokens in a php session, in a database, or in memcache. It does not require php sessions unless a partner wants it to.
9 This means there is no method equivalent to 'hasSession' or 'requireSession'. An example of how this functionality could be implemented is in the yos-social-php5/examples/simpleauth/simpleauth.php._**
10
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
11
12 Find documentation and support on Yahoo! Developer Network: http://developer.yahoo.com
13
14 * Yahoo! Application Platform - http://developer.yahoo.com/yap/
15 * Yahoo! Social APIs - http://developer.yahoo.com/social/
16 * Yahoo! Query Language - http://developer.yahoo.com/yql/
17
18 Hosted on GitHub: http://github.com/yahoo/yos-social-php5/tree/master
19
20 License
21 =======
22
23 @copyright: Copyrights for code authored by Yahoo! Inc. is licensed under the following terms:
24 @license: BSD Open Source License
25
26 Yahoo! Social SDK
27 Software License Agreement (BSD License)
28 Copyright (c) 2009, Yahoo! Inc.
29 All rights reserved.
30
31 Redistribution and use of this software in source and binary forms, with
32 or without modification, are permitted provided that the following
33 conditions are met:
34
35 * Redistributions of source code must retain the above
36 copyright notice, this list of conditions and the
37 following disclaimer.
38
39 * Redistributions in binary form must reproduce the above
40 copyright notice, this list of conditions and the
41 following disclaimer in the documentation and/or other
42 materials provided with the distribution.
43
44 * Neither the name of Yahoo! Inc. nor the names of its
45 contributors may be used to endorse or promote products
46 derived from this software without specific prior
47 written permission of Yahoo! Inc.
48
49 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
50 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
51 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
52 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
53 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
54 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
55 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
56 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
57 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
58 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59
60
61 The Yahoo! Social PHP SDK code is subject to the BSD license, see the LICENSE file.
62
63
64 Requirements
65 ============
66
67 The following dependencies are bundled with the Yahoo! PHP SDK, but are under
68 terms of a separate license. See the bundled LICENSE files for more information:
69
70 * OAuth - http://code.google.com/p/oauth
71 * OpenID - http://www.openidenabled.com/php-openid/
72 * OpenSocial - http://code.google.com/p/opensocial-php-client/
73 * JSON - http://pear.php.net/Services_JSON
74
75
d44549e @dustinwhittle added opensocial example for fetching profiles / activity + updated R…
dustinwhittle authored Aug 26, 2009
76 Installation
77 ============
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
78
79 After downloading and unpacking the release, copy the contents of 'lib'
80 to a directory that is accessible via the PHP include_path method.
81
82
83 Examples
84 ========
85
d44549e @dustinwhittle added opensocial example for fetching profiles / activity + updated R…
dustinwhittle authored Aug 26, 2009
86 The sdk comes with example code, but you must first upcate the file
87 'examples/common.inc.php' with your OAuth consumer key and secret.
88
89
90 define('OAUTH_CONSUMER_KEY', '###');
91 define('OAUTH_CONSUMER_SECRET', '###');
92 define('OAUTH_DOMAIN', '###');
93 define('OAUTH_APP_ID', '###');
94
95
96 Create OAuth applications in the Yahoo! Developer Dashboard:
97
98 http://developer.yahoo.com/dashboard/
99
100
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
101 ## Fetching YQL:
102
d44549e @dustinwhittle added opensocial example for fetching profiles / activity + updated R…
dustinwhittle authored Aug 26, 2009
103 See the bundled sample code in examples/yql/delicious.php.
104
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
105 $yql = new YahooYQLQuery();
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored Aug 26, 2009
106 $response = $yql->execute('select * from delicious.feeds.popular');
107
108 if(isset($response->query) && isset($response->query->results))
109 {
110 var_dump($response->query->results);
111 }
112 elseif(isset($response->error))
113 {
114 print sprintf('YQL query failed with error: "%s".', $response->error->description);
115 }
116 else
117 {
118 print 'YQL response malformed.';
119 }
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
120
121
122 ## Fetching Social Data:
123
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored Aug 26, 2009
124 # Yahoo! OAuth Credentials - http://developer.yahoo.com/dashboard/
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
125
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored Aug 26, 2009
126 $CONSUMER_KEY = '##';
127 $CONSUMER_SECRET = '##';
128 $APPLICATION_ID = '##';
129 $CALLBACK_URL = '##';
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
130
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored Aug 26, 2009
131 $oauthapp = new YahooOAuthApplication($CONSUMER_KEY, $CONSUMER_SECRET, $APPLICATION_ID, $CALLBACK_URL);
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
132
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored Aug 26, 2009
133 # Fetch request token
9a1eb56 @dustinwhittle updated oauth example to use oauth1.0a
dustinwhittle authored Oct 13, 2009
134 $request_token = $oauthapp->getRequestToken($CALLBACK_URL);
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
135
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored Aug 26, 2009
136 # Redirect user to authorization url
9a1eb56 @dustinwhittle updated oauth example to use oauth1.0a
dustinwhittle authored Oct 13, 2009
137 $redirect_url = $oauthapp->getAuthorizationUrl($request_token);
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
138
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored Aug 26, 2009
139 # Exchange request token for authorized access token
9a1eb56 @dustinwhittle updated oauth example to use oauth1.0a
dustinwhittle authored Oct 13, 2009
140 $access_token = $oauthapp->getAccessToken($request_token, $_REQUEST['oauth_verifier']);
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
141
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored Aug 26, 2009
142 # update access token
143 $oauthapp->token = $access_token;
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
144
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored Aug 26, 2009
145 # fetch user profile
146 $profile = $oauthapp->getProfile();
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
147
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored Aug 26, 2009
148 var_dump($profile);
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
149
027f49d @zagraves updated readme
zagraves authored May 26, 2010
150 ## Inserting Updates
151
152 $oauthapp = new YahooOAuthApplication($CONSUMER_KEY, $CONSUMER_SECRET, $APPLICATION_ID, $CALLBACK_URL);
153
154 $title = "cloned the yos-social-php5 SDK on Github";
155 $description = "PHP 5 SDK for YQL";
156 $link = "http://github.com/yahoo/yos-social-php5";
157
158 $oauthapp->insertUpdate(null, $description, $title, $link, $suid);
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
159
160 ## Signing with SimpleAuth (OpenID + OAuth):
161
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored Aug 26, 2009
162 See the bundled sample code in examples/simpleauth/simpleauth.php.
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
163
164
d44549e @dustinwhittle added opensocial example for fetching profiles / activity + updated R…
dustinwhittle authored Aug 26, 2009
165 ## Fetching people and activities with OpenSocial:
166
167 See the bundled sample code in examples/opensocial/profile.php.
168
169
fabd065 updated readme with addContact example
basictheory authored Oct 9, 2009
170 ## Adding a Contact:
171
172 # valid 'Yahoo! Contacts Read/Write' scopes are required to support this method.
173
174 $contact_fields = array();
175 $contact_fields[] = array('type' => 'email', 'value' => 'me@domain.com');
176 $contact_fields[] = array('type' => 'name', 'value' => array('givenName'=> 'John', 'familyName' => 'Doe'));
177 $contact = array('fields' => $contact_fields);
178
179 var_dump($oauthapp->addContact($contact));
180
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored Aug 20, 2009
181 Tests
182 =====
183
184 The Yahoo! PHP SDK comes with a test suite to validate functionality. The tests also
185 show functional examples and results. To run the test suite, simply execute the test suite:
186
187 php phpunit test/AllTests.php
Something went wrong with that request. Please try again.