diff --git a/src/facebook/sdk/FacebookApp.cfc b/src/facebook/sdk/FacebookApp.cfc index 68dce93..c5290d9 100644 --- a/src/facebook/sdk/FacebookApp.cfc +++ b/src/facebook/sdk/FacebookApp.cfc @@ -1,9 +1,8 @@ /** - * Copyright 2010 Affinitiz - * Title: FacebookApp.cfc + * Copyright 2010 Affinitiz, Inc. * Author: Benoit Hediard (hediard@affinitiz.com) * Date created: 01/08/10 - * Last update date: 11/09/10 + * Last update date: 09/09/10 * Version: V2.1.1 beta1 * * Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -26,43 +25,43 @@ component { /** - * @description Facebook App URL - * @hint Ex.: http://apps.facebook.com/your-app - */ - property String appUrl; - /** - * @description Facebook App Id - * @hint - * @validate string - */ - property String appId; - /** - * @description Facebook application secret key - * @hint - * @validate string - */ - property String secretKey; - /** - * @description Canvas or Site URL - * @hint Ex.: http://youserver.com/yourapp - */ - property String siteUrl; + * @description Facebook App URL + * @hint Ex.: http://apps.facebook.com/your-app + */ + property String appUrl; + /** + * @description Facebook App Id + * @hint + * @validate string + */ + property String appId; + /** + * @description Facebook application secret key + * @hint + * @validate string + */ + property String secretKey; + /** + * @description Canvas or Site URL + * @hint Ex.: http://youserver.com/yourapp + */ + property String siteUrl; - variables.DROP_QUERY_PARAMS = "session,signed_request"; - variables.VERSION = '2.1.1'; + variables.DROP_QUERY_PARAMS = "session,signed_request"; + variables.VERSION = '2.1.1'; - /* - * @description Facebook App constructor - * @hint Requires an appId and its secretKey - */ - public FacebookApp function init(required String appId, required String secretKey, String appUrl = "", String siteUrl = "") { - setAppUrl(arguments.appUrl); - setAppId(arguments.appId); - setSecretKey(arguments.secretKey); - setSiteUrl(arguments.siteUrl); - //variables.accessTokenHttpService = new Http(url="https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=#variables.appId#&client_secret=#variables.secretKey#"); - return this; - } + /* + * @description Facebook App constructor + * @hint Requires an appId and its secretKey + */ + public FacebookApp function init(required String appId, required String secretKey, String appUrl = "", String siteUrl = "") { + setAppUrl(arguments.appUrl); + setAppId(arguments.appId); + setSecretKey(arguments.secretKey); + setSiteUrl(arguments.siteUrl); + //variables.accessTokenHttpService = new Http(url="https://graph.facebook.com/oauth/access_token?type=client_cred&client_id=#variables.appId#&client_secret=#variables.secretKey#"); + return this; + } /* * @description Dump parameters for debug purpose. @@ -179,17 +178,27 @@ component { public Numeric function getProfileId() { var parameters = structNew(); var profileId = 0; - if (structKeyExists(url, "signed_request")) { - parameters = parseSignedRequestParameters(url.signed_request); - } else if (structKeyExists(form, "signed_request")) { - parameters = parseSignedRequestParameters(form.signed_request); - } + parameters = parseSignedRequestParameters(getSignedRequest()); if (structKeyExists(parameters, "profile_id")) { profileId = parameters.profile_id; } return profileId; } + /* + * @description Get signed request + * @hint + */ + public String function getSignedRequest() { + var signedRequest = ""; + if (structKeyExists(url, "signed_request")) { + signedRequest = url.signed_request; + } else if (structKeyExists(form, "signed_request")) { + signedRequest = form.signed_request; + } + return signedRequest; + } + /* * @description Get user OAuth accessToken * @hint @@ -220,14 +229,12 @@ component { * @description Get the session object. * @hint This will automatically look for a signed session sent via the signed_request, Cookie or Query Parameters if needed. */ - public Struct function getUserSession() { + public Struct function getUserSession(String signedRequest = "") { var parameters = structNew(); var userSession = structNew(); // Try loading session from url.signed_request or form.signed_request - if (structKeyExists(url, "signed_request")) { - parameters = parseSignedRequestParameters(url.signed_request); - } else if (structKeyExists(form, "signed_request")) { - parameters = parseSignedRequestParameters(form.signed_request); + if (signedRequest == "") { + parameters = parseSignedRequestParameters(getSignedRequest()); } if (structCount(parameters)) { userSession = createSessionFromSignedRequestParameters(parameters); @@ -399,7 +406,7 @@ component { } return parameters; } - + private Struct function parseSignedRequestParameters(required String signedRequest) { var encodedParameters = listLast(trim(arguments.signedRequest), "."); var encodedSignature = listFirst(trim(arguments.signedRequest), "."); @@ -413,7 +420,7 @@ component { } return parameters; } - + private Boolean function validateUserSession(required Struct userSession) { var valid = false; if (isStruct(arguments.userSession) diff --git a/src/facebook/sdk/FacebookRestAPI.cfc b/src/facebook/sdk/FacebookRestAPI.cfc index 2681ae2..73457c1 100644 --- a/src/facebook/sdk/FacebookRestAPI.cfc +++ b/src/facebook/sdk/FacebookRestAPI.cfc @@ -4,7 +4,7 @@ * Author: Benoit Hediard (hediard@affinitiz.com) * Date created: 01/08/10 * Last update date: 11/09/10 - * Version: V2.1.1 beta1 + * Version: V2.1.2 beta1 * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain @@ -105,11 +105,11 @@ component { return result['aid']; } - public String function publishPhoto(required String profileId, required String aid, required String sourcePath, String message = "") { + public String function publishPhoto(required String profileId, required String albumId, required String sourcePath, String message = "") { var result = structNew(); var httpService = new Http(url="https://api.facebook.com/method/photos.upload", method="POST"); httpService.addParam(type="url", name="access_token", value="#variables.ACCESS_TOKEN#"); - httpService.addParam(type="formField", name="aid", value="#arguments.aid#"); + httpService.addParam(type="formField", name="aid", value="#arguments.albumId#"); httpService.addParam(type="formField", name="uid", value="#arguments.profileId#"); httpService.addParam(type="file", name="data", file="#arguments.sourcePath#"); httpService.addParam(type="url", name="format", value="json");