I'm trying to integrate the klarna api:
https://developers.klarna.com/en/us/kco-v3/checkout/javascript-api
Unfortunately when I do:
window._klarnaCheckout(function(api) {
api.on({
'change': function(data) {
console.log(data);
}
});
});
This only returns the zip and postal_code but not the entered email address or other information like the name.
Is this a klarna issue or am I missing something?
Only once the form within the Klarna iframe is submitted, the event is triggered, and information is returned. Unfortunately, I have only managed to get it to return email, postal_code, country, given_name and family_name. Address doesn't seem to want to play.
Hope this helps (at least a little).
Related
I find ObjectFilter doesn't work in SoftLayer.
I even tried the example provided in the SoftLayer webpage here:
https://sldn.softlayer.com/article/object-filters
REST:
List the ID and hostname of all servers in dal05
https://api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests?objectMask=mask[id,hostname]&objectFilter={"datacenter":{"name":{"operation":"dal05"}}}
When I ran this command, it still returns all the virtual guests, regardless what data center that virtual guest belongs to.
try this request:
GET https://api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests?objectMask=mask[id,hostname,datacenter]&objectFilter={"virtualGuests":{"datacenter":{"name":{"operation":"dal05"}}}}
The issue with your request is that you are missing the "virtualGuests" property, keep in mind that the objectFilter is filtering over the data in the database, so you need to tell it over what table work and over what record of the table work. e.g. using the "SoftLayer_Account" that implies that all the work will be over the "SoftLayer_Account" table now you need to tell id over what property/record of that table work in this case you need to work over the "virtualGuests" and so on. Please keep in mind that and you review the documentation about the valid properties/records e.g. these are the valid properties/record for Softlayer_Account:
http://sldn.softlayer.com/reference/datatypes/SoftLayer_Account
Regards
Maybe you can try adding virtualGuestsin the filter, something like this:
objectFilter={ "virtualGuests": { "datacenter": { "longName": { "operation": "Dallas 6" } } } }
or please see the first examples of https://sldn.softlayer.com/article/object-filters, like this:
object_filter = {
'virtualGuests': {
'datacenter': {
'name': {'operation': 'dal05'}
}
}
}
in keystoneJs's doc:
Populating related data in queries
You can populate related data for relationship fields thanks to Mongoose's populate functionality. To populate the author and category documents when loading a Post from the example above, you would do this:
Post.model.findOne().populate('author categories').exec(function(err,post) {
// the author is a fully populated User document
console.log(post.author.name);
});
my question is that there is any options I can configure so these List APIs can populate the many relationship automatically.
thanks.
mike so
I think not. This is how I do it when I use Keystone as an API (using .populate).
exports.getStoreWithId = function (req, res) {
Store.model
.find()
.populate('productTags productCategories')
.where('_id', req.params.id)
.exec(function (err, item) {
if (err) return res.apiError('database error', err);
res.apiResponse({
store: item,
});
});
};
Pretty sure the short answer here is no. If you want to populate you'll need to include the .populate.
That being said, keystone gives you access to the mongoose schema, so the answer here should work. Obviously their mongoose.Schema is done by your Post.add stuff so I think you can ignore their first snippet, and you should be able to add the hooks as Post.schema.pre(... for the second snippet.
The Post.schema.pre('save',... hooks definitely work with keystone, so I assume the pre-find hooks work too, however I've not actually tested this. (I'd be interested to know the outcome though!)
Finally, if that works, you could also have a look at the mongoose-autopopulate package, and see if you can get that to play nicely with keystone.
Let's say I have a REST API, which has basic methods to retrieve users and the photos of a user. For example:
// Get a user:
GET /user/123
// Get the photos of a user:
GET /user/123/photos
// Get a photo:
GET /photo/789
This is quite straightforward, however now I also need a method to retrieve the number of photos for a particular user. I don't want to retrieve all the photos because that would slow everything down and is not necessary. What would be the best way to do that in a REST API?
I thought about implementing something like GET /user/123/photo_count however "photo_count" is not a resource so that doesn't seem right.
How would I go about presenting this kind of information properly in a REST API?
// Get the photos of a user:
GET /user/123/photos
This does not have to actually return the photos, it could return just a list of links.
It could even be a partial list of the first n links with information on the total number, and links to get the next/prev batch.
You could do something a little "custom" like returning the count as a response header. Then to just get the count you would issue a HEAD which should return the headers with no response body (i.e.. not actually load the photos).
GET /user/123/photos
==>
Headers:
X-Count 23
Body:
<photos>
<photo id="1">...</photo>
<photo id="2">...</photo>
...
</photos>
HEAD /user/123/photos
==>
Headers:
X-Count 23
Body:
none
Like the comment on the original post, you can return the photo count as a property of your user "object". The GET /user/123 call would simply return an object/json/xml that contains the number of pictures as a property.
Here are the yammer api docs: http://developer.yammer.com/restapi/
Am I missing something here? How can I get the messages for a specific group? There seems to be a good deal of undocumented functionality.
I agree the documentation appears lacking.
Maybe:
https://www.yammer.com/api/v1/messages/in_group/<<GROUPID>>.json?access_token=<<ACCESSTOKEN>>"
via http://balamurugankailasam.blogspot.com/2012/10/displaying-yammer-feed-private-group-in.html
Embeded feeds support this functionailty:
feedType – Type of Feed to be displayed: group, topic, user, or Open Graph object
feedID – ID of the group, topic, or user feed (not applicable for Open Graph or My Feed)
Example
<script data-app-id="hyB2pTvrL36Y50py8EWj6A" src="https://assets.yammer.com/platform/yam.js"></script>
<script>
yam.connect.embedFeed(
{ container: '#embedded-feed',
network: 'fourleaf.com',
feedType: 'group', // can be 'group', 'topic', or 'user'
feedId: '123' // feed ID from the instructions above
});
</script>
<div id="embedded-feed"></div>
via http://developer.yammer.com/connect/
few month ago i write something to get the latitude or longitude from google API. latter i get the database from drupal for latitude or longitude to most of city in worlds.
but the problem is that the same city name can be found two or more times in a area. like Firozabad in India and bangladesh both. Agra in UP and agar in Rajasthan.
means the confusion in name by user if they found two city by same name they are confused.
i hear that HTML 5 support latitude or longitude of the visiter but i need latitude or longitude where they are born or city they want to use to fill a form.
how i can get the latitude or longtiude from API like google and some other.
the process is that:
user put the location in textbox for getting their latitude or longitude.
for right thing i want to show them all location [if same thing found more then one].
they can choose the right location and after click they can get the lati and langitude.
how i can do this using any API.
If I understood you correctly then here's a Javascript function that returns a list of actual locations based on the address (full or partial) that user has entered:
getLocationsByAddress = function(address, onComplete) {
var geocoder = null;
var locations = [];
var location = null;
geocoder = new GClientGeocoder();
geocoder.getLocations(address, function(response) {
if (!response || response.Status.code != 200) {
if (typeof (onComplete) != 'undefined') {
onComplete([]);
}
} else {
for (var i = 0; i < response.Placemark.length; i++) {
location = response.Placemark[i];
locations[locations.length] = {
address: location.address,
x: location.Point.coordinates[1],
y: location.Point.coordinates[0],
zoom: 14
}
}
if (typeof (onComplete) != 'undefined') {
onComplete(locations);
}
}
});
}
The code uses API version 2 but I think it should be fairly easy to make it work with V3 (please see this API reference for details).
UPDATE
As #Maxym stated the V2 API is considered as deprecated and therefore shouldn't be used any further.
Take a look at this jQuery plugin. It claims to work with both V2 and V3 so you may want to examine the source code in order to find out how they do an it with V3.
I am not sure that it is about HTML 5. You just need to create sort of hints, where user can select which exactly city she means (the way Google does on maps.google.com - you enter "Odessa" and see list of cities with such name). Google has geocoder API but probably it should be used with Google Map (just read license).
So the process is easy: user enters city, you send it to geocoder to get list of cities with such a name and their coordinates. THen you show that list, user selects one and you have its coordinates.
There is documentation how to use Geocoding API v3 in JavaScript, as well as examples. This one show how to get coordinates from address, take into account that they process results[0] only, but you need to iterate over results to get all cities.