Plugin Directory

Changeset 1876970


Ignore:
Timestamp:
05/18/2018 08:10:30 AM (8 years ago)
Author:
alive5sms
Message:

Updated to v2

Location:
alive5/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • alive5/trunk/admin/class-alive5-admin-settings.php

    r1773974 r1876970  
    5454        $defaults = array(
    5555            'a5_auth_url'   =>  'https://api.alive5.com/1.0/authuser',
    56             'a5_widgets_url'    =>  'https://api.alive5.com/1.0/org/get-widgets'
     56            'a5_widgets_url'    =>  'https://api.alive5.com/1.0/widget-code/get-all'
    5757        );
    5858
     
    161161                return false;
    162162            }
    163             $request = wp_remote_get("$a5_widgets_url");
     163            $a5_jwt = get_option('a5_jwt');
     164            $request = wp_remote_get("$a5_widgets_url", array(
     165                'headers' => array(
     166                    'authorization' => $a5_jwt
     167                )
     168            ));
    164169            if (is_wp_error($request)) {
     170                // var_dump($request);
    165171                echo '<h2 style="color: red;">Error occured while fetching widgets, check settings</h2>';
    166172                return false;
     
    203209            $defaults = $this->alive5_defaults();
    204210            $a5_auth_creds = get_option('a5_settings');
    205             $auth_url = $defaults['a5_auth_url'].'?org_name='.$a5_auth_creds['a5_org_name'].'&email='.$a5_auth_creds['a5_username'].'&password='.$a5_auth_creds['a5_password'];
    206                 $request = wp_remote_get("$auth_url");
     211            // $auth_url = $defaults['a5_auth_url'].'?org_name='.$a5_auth_creds['a5_org_name'].'&email='.$a5_auth_creds['a5_username'].'&password='.$a5_auth_creds['a5_password'];
     212                $request = wp_remote_post($defaults['a5_auth_url'], array(
     213                        'body' => array(
     214                            'org_name' => $a5_auth_creds['a5_org_name'],
     215                            'email' => $a5_auth_creds['a5_username'],
     216                            'password' => $a5_auth_creds['a5_password']
     217                        )
     218                ));
    207219               
    208220                if( is_wp_error( $request ) ) {
     
    211223                $body = wp_remote_retrieve_body($request);
    212224                $data = json_decode($body);
     225                // print_r($data);
    213226                if (!empty($data->data->jwt)) {
    214227                    add_option('a5_jwt', $data->data->jwt);
  • alive5/trunk/public/class-alive5-public.php

    r1773974 r1876970  
    107107                $options = get_option('a5_settings');
    108108                $jwt = get_option('a5_jwt');
    109                 $url = 'https://api.alive5.com/1.0/org/widget?org_name='.$options['a5_org_name'].'&widget_id='.$widget['widget_id'];
    110                 $args = array('Authorization' => $jwt);
     109                $url = 'https://api.alive5.com/1.0/widget-code/get-by-id?org_name='.$options['a5_org_name'].'&widget_id='.$widget['widget_id'];
     110                $args = array( 'headers' => array('authorization' => $jwt));
    111111                $request = wp_remote_get("$url", $args);
    112112               
Note: See TracChangeset for help on using the changeset viewer.