在这里,我被困在shopify通过API创建网络挂接创建使用API在shopify
我使用的蛋糕PHP创建公共shopify应用
现在我想创建推车/更新钩我的应用程序一个网络挂接这里使用的API是我的代码 蛋糕PHP库:https://github.com/cmcdonaldca/CakePHP-Shopify-Plugin
文件: ShopifyApiComponent.php
CODE:
public function createwebhook($shop_domain, $access_token){
$method = "POST";
$path = "/admin/webhooks.json";
$params = array("webhook" => array("topic"=>"carts/create",
"address"=> $this->site_url."users/upUpdateCart",
"format"=> "json"));
$password = md5($this->secret.$access_token);//If your shopify app is public
$baseurl = "https://".$this->api_key.":".$password."@".$shop_domain."/";
$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();
$request_headers = in_array($method, array('POST','PUT')) ? array("Content-Type: application/json; charset=utf-8", 'Expect:') : array();
$request_headers[] = 'X-Shopify-Access-Token: ' . $access_token;
list($response_body, $response_headers) = $this->Curl->HttpRequest($method, $url, $query, $payload, $request_headers);
$this->last_response_headers = $response_headers;
$response = json_decode($response_body, true);
if (isset($response['errors']) or ($this->last_response_headers['http_status_code'] >= 400))
$body = $response['errors'];
else
$body = $response_body;
/*Debug the output in a text_file*/
$destination = realpath('../../app/webroot/execution_log') . '/';
$fh = fopen($destination."shopify_app.txt",'a') or die("can't open file");
date_default_timezone_set('GMT');
fwrite($fh, "\n\nDATE: ".date("Y-m-d H:i:s")."\n".$body);
fclose($fh);
/*Debug Code Ends*/
return (is_array($response) and (count($response) > 0)) ? array_shift($response) : $response;
}
,我调用此函数当我访问我的应用程序仪表板意味着 控制器:信息 功能:仪表盘
但它不是好像,因为当我访问 https://test.myshopify.com/admin/webhooks.json其深藏不露,但 如果工作我我通过管理 - >设置 - >通知创建网络挂接那么它在这里展示上市https://test.myshopify.com/admin/webhooks.json
请让我知道我们如何使用API来创建网络挂接(蛋糕PHP)
有没有办法让我们在感谢页面上添加sone脚本 – Chauhan
我认为你不能在思想页面中定制任何东西(通过编码),因为谢谢你的页面属于checkout.shopify。 com域名和shopify不允许修改任何内容。但它的思想......可能有一种方法。 –