Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 179 lines (117 sloc) 6.027 kB
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
1 Yahoo! Social SDK - PHP5
8de7b17 @dustinwhittle updated README with alpha/experimental note
dustinwhittle authored
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
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
76 Installation
77 ============
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
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
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
101 ## Fetching YQL:
102
d44549e @dustinwhittle added opensocial example for fetching profiles / activity + updated R…
dustinwhittle authored
103 See the bundled sample code in examples/yql/delicious.php.
104
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
105 $yql = new YahooYQLQuery();
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored
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
120
121
122 ## Fetching Social Data:
123
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored
124 # Yahoo! OAuth Credentials - http://developer.yahoo.com/dashboard/
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
125
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored
126 $CONSUMER_KEY = '##';
127 $CONSUMER_SECRET = '##';
128 $APPLICATION_ID = '##';
129 $CALLBACK_URL = '##';
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
130
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored
131 $oauthapp = new YahooOAuthApplication($CONSUMER_KEY, $CONSUMER_SECRET, $APPLICATION_ID, $CALLBACK_URL);
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
132
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored
133 # Fetch request token
134 $request_token = $oauthapp->getRequestToken();
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
135
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored
136 # Redirect user to authorization url
137 $redirect_url = $oauthapp->getAuthorizationUrl($request_token, $CALLBACK_URL);
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
138
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored
139 # Exchange request token for authorized access token
140 $access_token = $oauthapp->getAccessToken($request_token);
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
141
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored
142 # update access token
143 $oauthapp->token = $access_token;
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
144
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored
145 # fetch user profile
146 $profile = $oauthapp->getProfile();
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
147
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored
148 var_dump($profile);
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
149
150
151 ## Signing with SimpleAuth (OpenID + OAuth):
152
fc069df @dustinwhittle fixed formatting in README
dustinwhittle authored
153 See the bundled sample code in examples/simpleauth/simpleauth.php.
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
154
155
d44549e @dustinwhittle added opensocial example for fetching profiles / activity + updated R…
dustinwhittle authored
156 ## Fetching people and activities with OpenSocial:
157
158 See the bundled sample code in examples/opensocial/profile.php.
159
160
fabd065 updated readme with addContact example
basictheory authored
161 ## Adding a Contact:
162
163 # valid 'Yahoo! Contacts Read/Write' scopes are required to support this method.
164
165 $contact_fields = array();
166 $contact_fields[] = array('type' => 'email', 'value' => 'me@domain.com');
167 $contact_fields[] = array('type' => 'name', 'value' => array('givenName'=> 'John', 'familyName' => 'Doe'));
168 $contact = array('fields' => $contact_fields);
169
170 var_dump($oauthapp->addContact($contact));
171
202169a @dustinwhittle initial import of experimental YOS PHP5 Social SDK
dustinwhittle authored
172 Tests
173 =====
174
175 The Yahoo! PHP SDK comes with a test suite to validate functionality. The tests also
176 show functional examples and results. To run the test suite, simply execute the test suite:
177
178 php phpunit test/AllTests.php
Something went wrong with that request. Please try again.