Prestashop quantities update through webservice - web-services

I'm building an API for a prestashop Website. I want to update my products from an external source
So i do a PUT Request on the product's stock_availables and that's fine as far as backoffice is concerned.
Although when i make a GET Request i get quantity=0
Any idea why?

Quantity is kept in stock_availables. You can try:
$xml = $webService->get([
'resource' => 'stock_availables',
'id' => $id,
]);
$quantity = $xml->stock_available->quantity;

Related

AWS Connect : How do I show company name on outbound calls instead of a phone number , or maybe both?

I have been trying to show up the company name instead of a phone number when an outbound call is initiated automatically at certain times using aws connect contact flow. So far, everything is working as it should be except for showing up the name of the company. I have been trying to find a solution or a documentation on how to show the company name instead of a number but so far could not find anything useful. the only hint I got from aws documentation was , I should set the caller id and name by myself, and no further instruction or hints on how to do it. I Tried to change the phone number using outboundcall api's contact attributes but nothing was showing up.
$result = $client->startOutboundVoiceContact([
'Attributes' => array(
'sourcePhoneNumber' => $d->company_name,
'd`enter code here`ate'=> $d->date,
'time' => $d->time,
'clinic' => $d->company_branch_name,
'address' => $d->company_branch_address,
),
'ContactFlowId' => $this->contactFlowId, // REQUIRED
'DestinationPhoneNumber' => $d->phone_number, // REQUIRED
'InstanceId' => $this->instanceId, // REQUIRED
'SourcePhoneNumber' => $this->sourcePhoneNumber,
]);
'''
where $d is my database and i am getting all the information from there
any recommendation or solution would be very much helpful. thank you.
If I recall correctly this feature is only possible in the US.

Migrate users data from django to drupal 7

Is there a way to migrate users data from django to drupal-7. I have 800 users in my old django website and want to migrate these users to drupal-7. Please suggest some tricks or tutorial. I googled a lot but was unable to find any direct solution.
Thank you for your help and suggestions.
I believe there is not an module for this, specifically. But the migrate module can help you with the migration. It demands that you create some code for the migration. But it is necessary only if your users have a lot of custom fields.
If they are simple users (username/email/password), you only would need to make a simple script to create users. In that case, you can use the drupal_bootstrap to start it from an external script and with user_save create the users.
<?php
define('DRUPAL_ROOT', '/path/to/drupal');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_boostrap(DRUPAL_BOOTSTRAP_FULL);
//set up the user fields
$fields = array(
'name' => 'user_name',
'mail' => 'user_name#example.com',
'pass' => $password,
'status' => 1,
'init' => 'email address',
'roles' => array(
DRUPAL_AUTHENTICATED_RID => 'authenticated user',
),
);
//the first parameter is left blank so a new user is created
$account = user_save('', $fields);

Amazon Product API - URL response

is there anyway to dynamically generate the response for the Amazon Product API with using just a URL string?
I see there are PHP and C# libraries but I am just trying to browse to a URL and see the response. I noticed one of the required fields of the URL is a timestamp which makes this tricky. The following page helped to generate the URLs but I can't seem to find a way to do it dynamically?
http://associates-amazon.s3.amazonaws.com/scratchpad/index.html
Thanks!
This is the dynamic search for amazon product
Download aws_signed_request.php from this url
include('aws_signed_request.php');
$public_key = 'xxxxxxxx';
$private_key = 'xxxxxxxxxx';
$associate_tag = 'xxxxxx';
$keywords= 'PHP';
$search_index = 'Books';
// generate signed URL
$request = aws_signed_request('com', array(
'Operation' => 'ItemSearch',
'Keywords' => "Php Books",
"SearchIndex" => "Books",
"Count" => '24',
'ResponseGroup' => 'Large,EditorialReview'), $public_key, $private_key, $associate_tag);
// do request (you could also use curl etc.)
$response = #file_get_contents($request);
Documentation URL HERE
I'm not sure I totally understand your question, but I think the answer is "the data in the Amazon product API is only available via 'signed' URLs". That way, Amazon can track abuse, etc back to the source (i.e. the signer).
If it were possible to get the data with a "static" URL, then you could post that URL all over the Internet and anyone could get the data without signing up with Amazon. It's their data, and they have rules on it's use, so that wouldn't fly with them.
That said, you can usually create URLs with a timestamp in the future (months or even years). But you would still be responsible for it's use/abuse.

How to use CUSTOM privacy setting for facebook post from an app in php

In PHP with facebook SDK, when I post from my app using /me/feed, if I use 'SELF' for privacy setting, it works fine. When I change it to CUSTOM with a list of ids to restrict to, I get an error for "friends" was not recognized. What does this mean?
// Works
$privacy = array(
'value' => 'SELF',
);
// Doesn't work and says 'Friends was not recognized'
$privacy = array(
'value' => 'CUSTOM',
'allow' => '{<id1>}'
}
I read through many questions on this topic before asking this one.
Also, this documentation from FB is confusing me as to what is and is not possible for an post from an app.
"Note: The privacy parameter only applies for posts to the user's own timeline and is ultimately governed by the privacy ceiling a user has configured for an app. It does not apply to posts made by an app on behalf of a user to another user's timelines or to Pages, events, or groups. In those cases, such posts are viewable by anyone who can see the timeline or content in the group or event."
you need to add a parameter called 'friends' with the value of 'SOME_FRIENDS'.
like this:
$privacy = array(
'value' => 'CUSTOM',
'friends' => 'SOME_FRIENDS',
'allow' => 'id1,id2,id3'
);

Facebook Graph API and FQL like count on photo's both incorrect?

Hey all,
I've made a facebook application for a contest, which allows users to upload their photo. Once uploaded, the photo gets posted to a dedicated album on their profile. Once the photo is there, the users should collect as many likes as possible.
Currently i have tried both the Facebook Graph API and Facebook FQL to retrieve the amount of likes, but the retrieved likes don't always match the likes on a users profile.
Some users claim to have more then 200 likes, yet the API only returned a maximum of 101 likes so far.
All users are requested to grant the application the following permissions:
user_hometown, publish_stream, read_stream, user_photos and offline_access
Using Facebook PHP SDK 3.0.1 I tried this FQL query to collect the amount of likes of a photo:
# fql query
$fql = "SELECT object_id FROM like WHERE object_id=" . $photo_id;
# api request
$request = array(
'method' => 'fql.query', 'query' => $fql
);
# run batch request
$likes = $this->facebook->api($request);
# return like count
return count($likes);
I also tried the following Graph API request (Also with Facebook PHP SDK 3.0.1) to collect the amount of likes of a photo:
$likes = $this->facebook->api($photo_id.'/likes');
return count($likes['data']);
Strangely, neither seem to return correct results. I can understand if the API is slightly inaccurate, but according to the API some pictures recieved 100 likes this morning and then 0 likes a few hours later.
Does anyone have any ideas what i might be doing wrong? Do the photo's and their albums need to be public? Do the people who liked the photo need to have a public profile in order to show up in the API? Do i need to request additional permissions?
Any help or suggestions will be greatly appreciated!
Just had the same problem here. The likes seems to be paginated by hundreds by default. Override this setting by using the "LIMIT" query option.
Does anyone have any ideas what i might be doing wrong?
yes, I believe that it is against Facebook policy to use their likes plugin for a contest. See: https://www.facebook.com/promotions_guidelines.php
# fql query
$fql = "SELECT like_info FROM photo WHERE object_id=" . $photo_id;
# api request
$request = array(
'method' => 'fql.query', 'query' => $fql
);
# run batch request
$likeInfo = $facebook->api(array(
'method' => 'fql.query', 'query' => $fql
));
var_dump($likeInfo);die;
=> get like info of photo