XeroPHP\Helpers::escape PHP Method

escape() public static method

In php, as simple as rawurlencode(). There were a lot more seemingly redundant transformations in the SimpleOAuth class.
public static escape ( $string ) : string
$string
return string
    public static function escape($string)
    {
        return rawurlencode($string);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Get the Signature Base String for signing.  This is basically just all params (including the generated oauth ones)
  * ordered by key, then concatenated with the method and URL
  * GET&https%3A%2F%2Fapi.xero.com%2Fapi.xro%2F2.0%2FContacts&oauth_consumer etc.
  *
  * @return string
  */
 public function getSBS()
 {
     $oauth_params = $this->getOAuthParams();
     $request_params = $this->request->getParameters();
     $sbs_params = array_merge($request_params, $oauth_params);
     //Params need sorting so signing order is the same
     ksort($sbs_params);
     $sbs_string = Helpers::flattenAssocArray($sbs_params, '%s=%s', '&', true);
     $url = $this->request->getUrl()->getFullURL();
     //Every second thing seems to need escaping!
     return sprintf('%s&%s&%s', $this->request->getMethod(), Helpers::escape($url), Helpers::escape($sbs_string));
 }