This is the code I have right now:
public static function listProducts() {
require_once('inc/config/config.php');
try {
$webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
$opt = array('resource' => 'products', 'display' => 'full');
$xml = $webService->get($opt);
$resources = $xml->products->children();
}
catch (PrestaShopWebserviceException $e) {
$trace = $e->getTrace();
if($trace[0]['args'][0] = 404) echo "BAD ID";
else if ($trace[0]['args'][0] = 401) echo "BAD AUTH KEY";
else echo 'OTHER ERROR';
}
$output = json_encode($resources, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
echo $output;
}
How can I output specific resources/details about my products?
Right now this outputs everything.
Thank you!
I can suggest you to use webservices documentation for 1.5 version, in 1.6 lack of details.
$opt = array(
'resource' =>'customers',
'display' => '[birthday]',
'filter[firstname]' => '[John]',
'filter[lastname]' => '[DOE]'
);
http://doc.prestashop.com/display/PS15/Chapter+8+-+Advanced+Use#Chapter8-AdvancedUse-SortingFilters
Related
Do you know how via a web page usind the IPB APi allowinfg to doynload a file. Until now I can the see the files but it's not possible to download it. My result myfile:zip.3313213213
Thank you
Below my approach :
public function getFilesInformations(int $id)
{
$curl = curl_init( $this->communityUrl . 'api/downloads/files?id=' . $id . '&download&perPage=300');
$array = [
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_USERPWD => "{$this->apiKey}:",
CURLOPT_USERAGENT => "MyUserAgent/1.0"
];
curl_setopt_array( $curl, $array);
$response = curl_exec( $curl );
return $response;
}
My other function to get the file info
public function insertFilesInformations(int $id): bool
{
$json_result = $this->getFilesInformations($id);
$result = json_decode($json_result, true);
$i = 1;
if (is_array($result)) {
foreach ($result as $value) {
if (is_array($value)) {
foreach ($value as $file) {
$download = $file['files'][0]['url'];
var_dum($download);
}
}
}
}
return $download
}
the result is something like that : https://localhost/forum/uploads/monthly_2019_12/myfile_zip.a1fb44a2cb001aa6f3596ec4c6dfba16
I'm using the data from telegrams received Webhook but I am faced with this error
Webhook tested properly set.
In your opinion, what is the problem?
This is my code:
Route :
Route::post('setwebhook','BotController#setWebhook');
Route::post('updates','BotController#updates');
BotController :
public function setWebhook()
{
$res = Telegram::setWebhook([
'url' => 'https://example.com/telegram-sdk/public/updates'
]);
return $res;
}
public function updates()
{
$update = Telegram::getWebhookUpdates();
$chat_id = $update->getMessage()->getChat()->getId();
$text = $update->getMessage()->getText();
$name = $update->getMessage()->getChat()->getFirstName();
if ($text == '/start') {
Telegram::sendMessage([
'chat_id' => $chat_id,
'text' => 'Hello World'
]);
}
}
I have try to do my self this code to implement the automatic send bitcoin payments to faucet box but is some errors there I need help with.
and it give me this error
The bitcoinrotator.publiadds.org.pt page is not working bitcoinrotator.publiadds.org.pt can not process this request for time. 500
<?php
//custom parameters
$api_key = "my_api_key";
$userAddy = $_SESSION['user'];
require_once("faucetbox.php");
$currency = "BTC"; # or LTC or any other supported by FaucetBOX
$faucetbox = new FaucetBOX($api_key, $currency);
$users = array(
'user_id' => clean($user_id),
'user_name' => clean($user_name),
'user_email' => clean($user_email),
'user_pass' => clean($user_pass),
'user_points' => clean($user_points),
'user_wallet' => clean($user_wallet)
);
session_start();
include_once 'dbconnect.php';
if(!isset($_SESSION['user']))
{
header("Location: index.php");
}
$selfNav = mysqli_query($conn, "SELECT user_wallet, user_points FROM users WHERE user_id=".$_SESSION['user']);
$rowNav = mysqli_num_rows($selfNav);
$rowAssoc = mysqli_fetch_assoc($selfNav);
$balance = $rowAssoc['user_points'];
$wallet = $rowAssoc['user_wallet'];
//auto cashout if bal over 0.00010000
if($balance > 0.00010000){
$amount = $rowAssoc['user_points'];
$currency = "BTC";
$faucetbox = new Faucetbox($api_key, $currency);
$result = $faucetbox->send($wallet, $amount);
if($result["success"] === true){
$_SESSION['cashout'] = $result["html"];
//reset balance to zero
mysqli_query($conn, "UPDATE `users` SET user_points = 0 WHERE user_id = " . $_SESSION['user')];
header('Location: ../home.php');
?>
well there it is its work but it stay with some bug there but now its work
the error is
Array ( [user_wallet] => 111111111111111111111111111111111111 [user_points] => 0.00000010 ) Error en balance
<?php
session_start();//Session start is ALWAYS the first thing to do.
if(!isset($_SESSION['user']))
{
header("Location: index.php"); //Sending headers its the next thing to do. Always.
}
include_once 'dbconnect.php';
//custom parameters
$api_key = "my_api_key";
$userAddy = $_SESSION['user'];
require_once("faucetbox.php");
$currency = "BTC"; # or LTC or any other supported by FaucetBOX
$faucetbox = new FaucetBOX($api_key, $currency);
//$users = array(
// 'user_id' => clean($user_id),
// 'user_name' => clean($user_name),
// 'user_email' => clean($user_email),
// 'user_pass' => clean($user_pass),
// 'user_points' => clean($user_points),
// 'user_wallet' => clean($user_wallet)
//);
//You are mixing mysql and mysqli, you need to choose one. Since you are on a shared hosting, mysqli is probably
//not installed/available, so we will keep using mysql. mysqli is safer!
$selfNav = mysql_query("SELECT user_wallet, user_points FROM users WHERE user_id=".$_SESSION['user']);
$rowNav = mysql_num_rows($selfNav);
$rowAssoc = mysql_fetch_assoc($selfNav);
print_r($rowAssoc);
$balance = $rowAssoc['user_points'];
$wallet = $rowAssoc['user_wallet'];
//auto cashout if bal over 0.00010000
if($balance > 0.00010000){
$amount = $rowAssoc['user_points'];
$currency = "BTC";
$result = $faucetbox->send($wallet,$amount); //$amount);
if($result["success"] === true){
$_SESSION['cashout'] = $result["html"];
//reset balance to zero
mysql_query("UPDATE `users` SET user_points = 0 WHERE user_id = " . $_SESSION['user']);
echo "result sucess and location go";
//header('Location: ../home.php');
}else{
echo "Error on faucet";
var_dump($result);
//What happens if there is an error?
}
}else{
echo "do not have enough credit to cash out";
//what happens if they dont have enough balance?
}
?>
I'm trying to create a product rule using bigcommerce api but i get the error :
"array(1) { [0]=> object(stdClass)#1352 (2) { ["status"]=> int(400) ["message"]=> string(55) "The field 'adjustor' is not supported by this resource." } } "
this is my code :
$adjustor = new stdClass() ;
$adjustor->adjustor="absolute";
$adjustor->adjustor_value=14.25;
$rule = array(
"sort_order" => 0,
"is_enabled" => true,
"is_stop" => false,
"price_adjuster" => $adjustor,
"weight_adjuster" => null,
"is_purchasing_disabled" => false,
"purchasing_disabled_message" => "",
"is_purchasing_hidden" => false,
'conditions' => array($x, $y)
);
$result = Bigcommerce::createProductRule($productId, $rule);
echo '<pre>';
var_dump($result);
echo '</pre>';
if (!$result) {
$error = Bigcommerce::getLastError();
var_dump($error);
}
This just looks like a typo. You spelled adjustor instead of adjuster.
It should be:
$adjustor->adjuster="absolute";
$adjustor->adjuster_value=14.25;
I have a custom module I'm writing, part of what I want it to do is create a vote associated with a node, I'm trying to figure out how to call the voting API from my module. I loookd in the documentation but it's a little sparse.
Here is an example from a module I wrote a while ago.
while ($data = db_fetch_object($result)) {
$node = node_load($data->nid);
$node_terms = taxonomy_node_get_terms($node);
$vote['value'] = 0;
$vote['value_type'] = 'points';
foreach ($node_terms as $term) {
$vote['value'] = $vote['value'] + $users_tags[$term->name];
}
$vote['content_id'] = $node->nid;
if (isset($vote['content_id'])) {
votingapi_set_votes($vote);
}
}
Just another example of using this:
function _ept_set_vote($nid, $status, $uid = NULL) {
global $user;
$vote = array(
array(
'entity_type' => 'node',
'value' => 1,
'entity_id' => $nid,
'uid' => (!$uid) ? $user->uid : $uid,
'tag' => $status
)
);
votingapi_set_votes($vote, array());
}
I call it like this:
switch($task_status){
case('start'):
_ept_set_vote($nid, "Start");
break;
case('completed'):
_ept_set_vote($nid, "Completed");
break;
}