source: trunk/www.guidonia.net/wp/wp-content/plugins/fbconnect/fbConfig_php5.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 14 years ago
File size: 6.2 KB
Line 
1<?php
2/**
3 * @author: Javier Reyes Gomez (http://www.sociable.es)
4 * @date: 05/10/2008
5 * @license: GPLv2
6 */
7
8function fb_get_loggedin_user() {
9 try{
10 $fbclient = & facebook_client();
11 if ($fbclient)
12 return $fbclient->get_loggedin_user();
13 }catch (FacebookRestClientException $e) {
14 //echo "Facebook connect error:".$e->getCode();
15 }
16 return null;
17}
18
19function fb_user_getInfo($fb_user) {
20 try{
21 $fbclient = & facebook_client();
22 if ($fbclient){
23 $fbapi_client = & $fbclient->api_client;
24 $userinfo = $fbapi_client->users_getInfo($fb_user, "about_me,profile_url,first_name,last_name,birthday,current_location,locale,sex,pic,pic_with_logo,pic_small,pic_small_with_logo,pic_big_with_logo,pic_big,pic_square,pic_square_with_logo,affiliations,email_hashes,hometown_location,hs_info,education_history,interests,meeting_for,meeting_sex,movies,music,political,profile_update_time,proxied_email,quotes,relationship_status,religion,significant_other_id,timezone,tv,work_history");
25 if (isset($userinfo[0])){
26 return $userinfo[0];
27 }else{
28 return $userinfo;
29 }
30 }
31 }catch (FacebookRestClientException $e) {
32 //echo "Facebook connect error:".$e->getCode();
33 }
34 return null;
35}
36
37function fb_feed_getRegisteredTemplateBundles() {
38 try{
39 $fbclient = & facebook_client();
40 if ($fbclient){
41 $fbapi_client = & $fbclient->api_client;
42 return $fbapi_client->feed_getRegisteredTemplateBundles();
43 }
44 }catch (FacebookRestClientException $e) {
45 //echo "Facebook connect error:".$e->getCode();
46 }
47 return null;
48}
49
50function fb_feed_registerTemplateBundle($one_line_stories,$short_stories,$full_stories){
51 try{
52 $fbclient = & facebook_client();
53 if ($fbclient){
54 $fbapi_client = & $fbclient->api_client;
55 return $fbapi_client->feed_registerTemplateBundle($one_line_stories,$short_stories,$full_stories);
56 }
57 }catch (FacebookRestClientException $e) {
58 //echo "Facebook connect error:".$e->getCode();
59 }
60 return null;
61}
62
63function fb_feed_deactivateTemplateBundleByID($templateID){
64 try{
65 $fbclient = & facebook_client();
66 if ($fbclient){
67 $fbapi_client = & $fbclient->api_client;
68 $fbapi_client->feed_deactivateTemplateBundleByID($templateID);
69 }
70 }catch (FacebookRestClientException $e) {
71 //echo "Facebook connect error:".$e->getCode();
72 }
73 return null;
74}
75
76function fb_feed_getRegisteredTemplateBundleByID($templateID){
77 try{
78 $fbclient = & facebook_client();
79 if ($fbclient){
80 $fbapi_client = & $fbclient->api_client;
81 return $fbapi_client->feed_getRegisteredTemplateBundleByID($templateID);
82 }
83 }catch (FacebookRestClientException $e) {
84 //echo "Facebook connect error:".$e->getCode();
85 }
86 return null;
87}
88
89function fb_fql_query($query){
90 try{
91 $fbclient = & facebook_client();
92 if ($fbclient){
93 $fbapi_client = & $fbclient->api_client;
94 return $fbapi_client->fql_query($query);
95 }
96 }catch (FacebookRestClientException $e) {
97 //echo "Facebook connect error:".$e->getCode();
98 }
99 return null;
100}
101function fb_expire_session(){
102 try {
103
104 $fbclient = & facebook_client();
105 if ($fbclient && $fbclient->get_loggedin_user()!="") {
106 $fbclient->expire_session();
107 }
108 }catch (Exception $e) {
109 // nothing, probably an expired session
110 }
111}
112
113function fb_feed_publishUserAction($template_data){
114 try {
115 $fbclient = & facebook_client();
116 if ($fbclient){
117 $fbapi_client = & $fbclient->api_client;
118 $feed_bundle_id = get_option('fb_templates_id');
119 $fbapi_client->feed_publishUserAction( $feed_bundle_id,
120 json_encode($template_data) ,
121 null,
122 null,2);
123 }
124 }catch (Exception $e) {
125 // nothing, probably an expired session
126 }
127}
128
129function fb_events_get($uid=null, $eids=null, $start_time=null, $end_time=null, $rsvp_status=null){
130 try {
131 $fbclient = & facebook_client();
132 if ($fbclient){
133 $fbapi_client = & $fbclient->api_client;
134 return $fbapi_client->events_get( $uid, $eids, $start_time, $end_time, $rsvp_status);
135 }
136 }catch (Exception $e) {
137 // nothing, probably an expired session
138 }
139}
140
141function fb_photos_getAlbums($uid=null, $aids=null) {
142 try {
143 $fbclient = & facebook_client();
144 if ($fbclient){
145 $fbapi_client = & $fbclient->api_client;
146 return $fbapi_client->photos_getAlbums($uid, $aids);
147 }
148 }catch (Exception $e) {
149 // nothing, probably an expired session
150 }
151
152}
153
154function fb_photos_get($subj_id=null, $aid=null, $pids=null){
155 try {
156 $fbclient = & facebook_client();
157 if ($fbclient){
158 $fbapi_client = & $fbclient->api_client;
159 return $fbapi_client->photos_get($subj_id, $aid, $pids);
160 }
161 }catch (Exception $e) {
162 print_r($e);
163 echo "ERROR";
164 // nothing, probably an expired session
165 }
166}
167
168function fb_users_getStandardInfo($uids=null, $fields=null) {
169 try {
170 $fbclient = & facebook_client();
171 if ($fbclient){
172 $fbapi_client = & $fbclient->api_client;
173 return $fbapi_client->users_getStandardInfo($uids, $fields);
174 }
175 }catch (Exception $e) {
176 print_r($e);
177 echo "ERROR";
178 // nothing, probably an expired session
179 }
180
181}
182
183function fb_showFeedDialog(){
184 $template_data = $_SESSION["template_data"];
185 if (isset($template_data) && $template_data!=""){
186 echo "<script type='text/javascript'>\n";
187 //echo "jQuery(window).ready(function() {\n"; NO FUNCIONA COMO EL ONLOAD
188 echo "window.onload = function() {\n";
189 echo "FB.ensureInit(function(){\n";
190 echo " FB.Connect.showFeedDialog(".get_option('fb_templates_id').", ".json_encode($template_data).", null, null, FB.FeedStorySize.full , FB.RequireConnect.promptConnect);";
191 echo "});\n";
192 echo " };\n";
193 //echo " });\n";
194 echo " </script>";
195 $_SESSION["template_data"] = "";
196 }
197
198
199}
200
201function fb_hash($email) {
202 $normalizedAddress = trim(strtolower($email));
203 //crc32 outputs signed int
204 $crc = crc32($normalizedAddress);
205 //output in unsigned int format
206 $unsignedCrc = sprintf('%u', $crc);
207 $md5 = md5($normalizedAddress);
208 return "{$unsignedCrc}_{$md5}";
209}
210
211function fb_connect_registerUsers($accounts=null){
212 try {
213 $fbclient = & facebook_client();
214 if ($fbclient){
215 $fbapi_client = & $fbclient->api_client;
216 return $fbapi_client->connect_registerUsers(json_encode($accounts));
217 }
218 }catch (Exception $e) {
219 print_r($e);
220 echo "ERROR";
221 // nothing, probably an expired session
222 }
223}
Note: See TracBrowser for help on using the repository browser.