- Subscribe to RSS Feed
- Mark Thread as New
- Mark Thread as Read
- Float this Thread for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Hello,
I'm working to make a website for our staff to use, that has some information about the products in our store. Example could be a list of the costumers who has bought a certain product.
This should be possible through the Store/Order API and example:
curl https://api.weeblycloud.com/user/USER_ID/site/SITE_ID/store/order/ORDER_ID/item \ -H "X-Public-Key: YOURAPIKEY" \ -H "X-Signed-Request-Hash: YOURSECRETHASH"
For a test i tried to do the guide on https://cloud-developer.weebly.com/about-the-rest-apis.html and insertet the data to my site:
<?php echo "hello"; require_once("src/init.php"); ?> <?php
echo "Forsøg";
$sideid = "961961237632906202";
$brugerid ="117649224";
$base_api = "https://api.weeblycloud.com/";
$api_key = "XXXXXXXX/censored";
$api_secret = "XXXXXXXX/censored";
$request_type = "POST";
$url = "user/117649224/site";
$data = array(
"domain" => "fifopizza.dk"
);
$content = json_encode($data);
$hash = hash_hmac('SHA256', $request_type . "\n" . $url . "\n" . $content, $api_secret);
$hash = base64_encode($hash);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $base_api.$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request_type);
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-type: application/json',
'X-Public-Key: ' . $api_key,
'X-Signed-Request-Hash: ' . $hash
));
$out = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$result = json_decode($out);
if ($info['http_code'] === 200) {
echo "hej med dig";
} else {
echo "fejl";
}
?>
My question is:
How do I rewrite the above code to get, lets say the product id? I know the code is:
curl https://api.weeblycloud.com/user/USER_ID/site/SITE_ID/store/product \ -H "X-Public-Key: YOURAPIKEY" \ -H "X-Signed-Request-Hash: YOURSECRETHASH"
But where do i insert this in the above code? I think it has something to do with the variable $url and $request_type that should sat GET and then i should delete the $content variable from the hash string, but i can't workout how.. I simply just want it to post the product id.
Test site:
https://test.joachimschubert.dk/
Best regards
Joachim
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report
Hey @JSchubert
First, I would recommend using the Weebly Cloud PHP Client in your application if you aren't already. It is an open-source library that provides a reusable and improvable solution for interacting with our Cloud APIs.
Currently it does not include functionality for accessing "Products" or "Store", but I have spent time today creating the following Pull Request: https://github.com/Weebly/cloud-client-php/pull/7. I would like to see if you could fetch that PR, test it, and respond in the comments of the PR with your review please.
I have included documentation which shows how this should operate to answer your question here, and please do not hesitate to let me know if you have any questions, or if I missed anything please.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report
Any update if you were able to get this resolved, or need more assistance please @JSchubert?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report
Glad to hear you got things working again!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report