Example #1
0
 private function getOrderResponse($url, $method = 'GET', $postfields = false)
 {
     //print_r($postfields);exit;
     $etHttpObj = new etHttpUtils($this->consumer, $url, true, $method);
     if ($postfields) {
         $etHttpObj->setPostfields($postfields);
     }
     $etHttpObj->GetResponse();
     return $etHttpObj->response_body;
 }
Example #2
0
 /**
  *
  * @method getAccountsResponse
  * 	create a http call to server and get response.
  * @param string $url
  * @param string $method
  */
 private function getAccountsResponse($url, $method = 'GET')
 {
     $etHttpObj = new etHttpUtils($this->consumer, $url, true, $method);
     $etHttpObj->GetResponse();
     return $etHttpObj->response_body;
 }
Example #3
0
 * - Copy this file under Samples/ 
 * - It will use Samples/config.php
 *
 * - Configure following values : 
 * YOUR PUSH_URL
 * YOUR OAUTH_ACCESS_TOKEN
 * YOUR OAUTH_ACCESS_TOKEN_SECRET
 */
define('PUSH_URL', 'https://etwspush.etrade.com/apistream/cometd/oauth/');
define('OAUTH_ACCESS_TOKEN', 'your token');
define('OAUTH_ACCESS_TOKEN_SECRET', 'your secret');
require_once "config.php";
require_once dirname(__FILE__) . '/../Common/Common.php';
$consumer = new etOAuthConsumer(ETWS_APP_KEY, ETWS_APP_SECRET);
$consumer->oauth_token = OAUTH_ACCESS_TOKEN;
// YOUR ACCESS TOKEN
$consumer->oauth_token_secret = OAUTH_ACCESS_TOKEN_SECRET;
// YOUR ACCESS TOKEN.
$method = 'POST';
$etHttpObj = new etHttpUtils($consumer, GetURL(URL_ACCOUNTLIST), true, $method);
$token_obj = new OAuthToken($consumer->oauth_token, $consumer->oauth_token_secret);
$request_obj = OAuthRequest::from_consumer_and_token($consumer, $token_obj, $method, PUSH_URL, array());
$sig_method = new OAuthSignatureMethod_HMAC_SHA1();
$request_obj->sign_request($sig_method, $consumer, $token_obj);
$header_str = $request_obj->to_header();
echo "\n----headers---------\n";
print_r($header_str);
echo "\n--------------------\n";
$etHttpObj = new etHttpUtils($consumer, PUSH_URL, true, $method);
$etHttpObj->GetResponse();
print_r($etHttpObj);
Example #4
0
        }
    } catch (ETWSException $e) {
        echo "***Caught exception***  \n" . "Error Code \t: " . $e->getErrorCode() . "\n" . "Error Message \t: " . $e->getErrorMessage() . "\n";
        if (DEBUG_MODE) {
            echo $e->getTraceAsString() . "\n";
        }
        exit;
    } catch (Exception $e) {
        echo "***Caught exception***  \n" . "Error Code \t: " . $e->getCode() . "\n" . "Error Message \t: " . $e->getMessage() . "\n";
        if (DEBUG_MODE) {
            echo $e->getTraceAsString() . "\n";
        }
        echo "Exiting...\n";
        exit;
    }
    $mkt_responce_obj = etHttpUtils::GetResponseObject($out);
    print_r($mkt_responce_obj);
}
//---------------------------------------------------------
/**
 * Get command line input
 * @param
 */
function get_input($str)
{
    echo "\nPlease enter * {$str} * : ";
    return trim(fgets(STDIN));
}
function show_menu()
{
    echo "\n\nChoose from following options..\n\n";
Example #5
0
    } catch (ETWSException $e) {
        echo "***Caught ETWSException***  \n" . "Error Code \t: " . $e->getErrorCode() . "\n" . "Error Message \t: " . $e->getErrorMessage() . "\n";
        if (DEBUG_MODE) {
            echo $e->getTraceAsString() . "\n";
        }
        exit;
    } catch (Exception $e) {
        echo "***Caught Exception***  \n" . "Error Code \t: " . $e->getCode() . "\n" . "Error Message \t: " . $e->getMessage() . "\n";
        if (DEBUG_MODE) {
            echo $e->getTraceAsString() . "\n";
        }
        echo "Exiting...\n";
        exit;
    }
    $endtime = ETWSCommon::get_time();
    $ac_responce_obj = etHttpUtils::GetResponseObject($ac);
    print_r($ac_responce_obj);
    echo "\n totel time for optoin {$choice} : " . ETWSCommon::get_time_diff($starttime, $endtime);
}
/**
 * Get command line input
 * @param string $str
 */
function get_cmdline_input($str)
{
    echo "\nPlease enter * {$str} * : ";
    return trim(fgets(STDIN));
}
/**
 *
 * @method show_menu
Example #6
0
 /**
  *
  * @method UpdateToken
  * @param sting $url
  * @return string
  */
 private function UpdateToken($url)
 {
     $etHttpObj = new etHttpUtils($this, $url, true);
     $etHttpObj->GetResponse();
     return $etHttpObj->response_body;
 }