Permalink
Browse files

Adding core package

  • Loading branch information...
1 parent de247dd commit 6c4cf9a34653354f480f11a7649ddb774849c072 @sabyrzhan committed Nov 29, 2011
Showing with 107 additions and 0 deletions.
  1. +107 −0 lib/core/SCL_AbstractSocial.php
@@ -0,0 +1,107 @@
+<?php
+abstract class SCL_AbstractSocial {
+ const FORMAT_JSON = 'json';
+ const FORMAT_XML = 'xml';
+ const FORMAT_ATOM = 'atom';
+ const FORMAT_RSS = 'rss';
+
+ protected $aResult = array('data' => '', 'meta' => '');
+
+ protected $sFormat;
+
+ protected $bIsSecure;
+
+ protected $sAccessToken = '';
+
+ protected $sAccessTokenSecret = '';
+
+ protected $sApplicationKey = '';
+
+ protected $sApplicationSecret = '';
+
+ protected $sCallbackUrl = '';
+
+ protected $sSignatureMethod = '';
+
+ protected $sOAuthVersion = '';
+
+ public function getResult() {
+ return $this->aResult;
+ }
+
+ protected function setResultData($mData) {
+ $this->aResult['data'] = $mData;
+ }
+
+ protected function setResultMeta($mDataMeta) {
+ $this->aResult['meta'] = $mDataMeta;
+ }
+
+ /**
+ * <p>This functions is used for authorized get requests.</p>
+ * @param array $aParams <p>Various parameters, specific to child classes. Values are presented as key-values.</p>
+ * @return array <p>Result from the server, containing response data under "data" key and meta info about the request under "meta" key of the array.</p>
+ */
+ abstract public function getData($aParams = array());
+
+ /**
+ * <p>This functions is used for authorized post requests.</p>
+ * @param array $aParams <p>Various parameters, specific to child classes. Values are presented as key-values.</p>
+ * @return array <p>Result from the server, containing response data under "data" key and meta info about the request under "meta" key of the array.</p>
+ */
+ abstract public function postData($aParams = array());
+
+ public static function convertData($sFormat, $mData) {
+ if(!strlen(trim($mData))) return trim($mData);
+ switch($sFormat) {
+ case self::FORMAT_JSON:
+ return UTL_Utils::jsonDecode($mData);
+ case self::FORMAT_XML:
+ case self::FORMAT_RSS:
+ case self::FORMAT_ATOM:
+ return UTL_Utils::decodeXML($mData);
+ default:
+ return $mData;
+ }
+ }
+
+ public function setAccessToken($sAccessToken) {
+ $this->sAccessToken = $sAccessToken;
+ }
+
+ public function getAccessToken() {
+ return $this->sAccessToken;
+ }
+
+ public function setAccessTokenSecret($sAccessTokenSecret) {
+ $this->sAccessTokenSecret = $sAccessTokenSecret;
+ }
+
+ public function getAccessTokenSecret() {
+ return $this->sAccessTokenSecret;
+ }
+
+ public function setApplicationKey($sApplicationKey) {
+ $this->sApplicationKey = $sApplicationKey;
+ }
+
+ public function getApplicationKey() {
+ return $this->sApplicationKey;
+ }
+
+ public function setApplicationSecret($sApplicationSecret) {
+ $this->sApplicationSecret = $sApplicationSecret;
+ }
+
+ public function getApplicationSecret() {
+ return $this->sApplicationSecret;
+ }
+
+ public function setCallbackUrl($sCallbackUrl) {
+ $this->sCallbackUrl = $sCallbackUrl;
+ }
+
+ public function getCallbackUrl() {
+ return $this->sCallbackUrl;
+ }
+}

0 comments on commit 6c4cf9a

Please sign in to comment.