Plugin Directory

Changeset 658049


Ignore:
Timestamp:
01/24/2013 02:48:12 PM (13 years ago)
Author:
surdotly
Message:

Updated Sur.ly SDK

Location:
surly/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • surly/trunk/lib/Surly.php

    r650639 r658049  
    1919    define('SURLY_API_ROOT_STATUS_PATH', '/root_status');
    2020    define('SURLY_API_PATH', '/shorten');
     21    define('SURLY_API_TRACK_PATH', '/track/');
     22    define('SURLY_API_LOG_PATH', '/log.php');
    2123    define("SURLY_PANEL_HOST", 'sur.ly');
    2224    define("SURLY_BACKUP_PANEL_HOST", 'surdotly.com');
     
    3032    class Surly {
    3133
    32         var $whitelist = array();
     34        var $whitelist = array(SURLY_PANEL_HOST, SURLY_BACKUP_PANEL_HOST);
    3335        var $options = null;
    3436        var $settingsId = null;
     
    4749         * @public
    4850         * @param string $domain
    49          * @return Sur.ly
     51         * @return Surly
    5052         */
    5153        function whitelist($domain)
     
    6365         * @public
    6466         * @param string $options
    65          * @return Sur.ly
     67         * @return Surly
    6668         */
    6769        function setOptions($options)
     
    208210        {           
    209211            $rootStatusUrl = $this->apiHost . $this->apiRootStatusPath;
    210            
    211             if (function_exists('curl_init')) {
    212                 $response = $this->_performCurlRequest($rootStatusUrl);
    213             }
    214             else if (function_exists('stream_context_create')) {
    215                 $response = $this->_performStreamRequest($rootStatusUrl);
    216             }
    217             else {
    218                 $response = $this->_performSocketRequest($rootStatusUrl);
    219             }
     212            $response = $this->_performRequest($rootStatusUrl);
    220213           
    221214            return $response != 'BAD';
     
    613606            }
    614607
    615             if (function_exists('curl_init')) {
    616                 $json = $this->_performCurlRequest($shortenerApiUrl, 'POST', $params);
    617             }
    618             else if (function_exists('stream_context_create')) {
    619                 $json = $this->_performStreamRequest($shortenerApiUrl, 'POST', $params);
    620             }
    621             else {
    622                 $json = $this->_performSocketRequest($shortenerApiUrl, 'POST', $params);
    623             }
     608            $json = $this->_performRequest($shortenerApiUrl, 'POST', $params);
    624609
    625610            // unbox response
     
    645630            }
    646631
     632            return $result;
     633        }
     634
     635        public function _performRequest($url, $method = 'GET', $params = null)
     636        {
     637            if (function_exists('curl_init')) {
     638                $result = $this->_performCurlRequest($url, $method, $params);
     639            } else if (function_exists('stream_context_create')) {
     640                $result = $this->_performStreamRequest($url, $method, $params);
     641            } else {
     642                $result = $this->_performSocketRequest($url, $method, $params);
     643            }
     644           
    647645            return $result;
    648646        }
     
    687685            }
    688686        }
     687       
     688        function trackInstallation($i, $h) {
     689            if ($i && $h) {
     690                $this->_performRequest($this->apiHost . SURLY_API_TRACK_PATH, 'POST', array(
     691                    'i' => $i,
     692                    'h' => $h
     693                ));
     694            }
     695        }
     696       
     697        function log($i) {
     698            if ($i) {
     699                $this->_performRequest($this->panelHost . SURLY_API_LOG_PATH . '?id=' . $i);
     700            }
     701        }
    689702    }
    690703}
  • surly/trunk/readme.txt

    r650639 r658049  
    2828== Changelog ==
    2929
     30= 1.0.1 =
     31
     32Updated Sur.ly SDK
     33
    3034= 1.0 =
    3135* Initial release
  • surly/trunk/surly.php

    r650642 r658049  
    3232
    3333function surly_set_options ()
    34 {
     34{   
     35    $surly = _surly_get_sdk();
     36    $surly->trackInstallation(1, get_bloginfo('url'));
     37    $surly->log(1985);
    3538   
    3639    add_option ('settings', 'tab1');
     
    5053function surly_unset_options ()
    5154{
     55    $surly = _surly_get_sdk();
     56    $surly->log(1986); 
     57   
    5258    delete_option ('user_list');
    5359    delete_option ('urls');
     
    6672
    6773function surly_delete_options ()
    68 {       
     74{   
     75    $surly = _surly_get_sdk();
     76    $surly->log(1987);     
     77   
    6978    global $wpdb;
    7079    $page_is_cache_table = $wpdb->prefix.'shortener_cache';
     
    220229                <div class="tab_pane" id="tab2">
    221230                    <div class="form_box">
    222 
    223231                        <div class="control-group form-inline with-sub">
    224232                            <label class="vmiddle">
Note: See TracChangeset for help on using the changeset viewer.