Permalink
Browse files

Counting for HTML with JSON; slashes need to be included for HTML.

  • Loading branch information...
1 parent 1f53827 commit 029d5025b2d5acfa376d2160cbd9845189d9a06d @nyalex committed Oct 30, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 client.php
View
@@ -41,6 +41,7 @@ function oauth_access_token($shop, $api_key, $shared_secret, $code)
function client($shop, $shops_token, $api_key, $shared_secret, $private_app=false)
+ public function call($method, $path, $params=array(), $striplashes = TRUE)
{
$password = $shops_token;
$baseurl = "https://$shop/";
@@ -50,6 +51,14 @@ function client($shop, $shops_token, $api_key, $shared_secret, $private_app=fals
$url = $baseurl.ltrim($path, '/');
$query = in_array($method, array('GET','DELETE')) ? $params : array();
$payload = in_array($method, array('POST','PUT')) ? stripslashes(json_encode($params)) : array();
+ if ($striplashes) {
+ $payload_data = stripslashes(json_encode($params));
+ } else {
+ $payload_data = json_encode($params);
+ }
+
+ $payload = in_array($method, array('POST','PUT')) ? $payload_data : array();
+
$request_headers = array();
array_push($request_headers, "X-Shopify-Access-Token: $shops_token");

1 comment on commit 029d502

edward commented on 029d502 Oct 31, 2012

Sweet! Are you going to send a pull request to @sandeepshetty so he can merge it back in?

Please sign in to comment.