How would be the JSON is in this example? - typeahead

$('.example-films .typeahead').typeahead([{name: 'best-picture-winners',
remote: '../data/films/queries/%QUERY.json',prefetch: '../data/films/post_1960.json',
template: '{{value}} – {{year}}',engine: Hogan}]);
how would be the JSON file written on this example.
i get this from typeahead js examples

If you view the source of the page you can see that there is an attached javascript file at http://twitter.github.io/typeahead.js/js/examples.js
Here you can view how they bound the typeahead box:
$('.example-films .typeahead').typeahead([
{
name: 'best-picture-winners',
remote: '../data/films/queries/%QUERY.json',
prefetch: '../data/films/post_1960.json',
template: '<p><strong>{{value}}</strong> – {{year}}</p>',
engine: Hogan
}
]);
And you will see that you can access prefetch JSON data to see the formatting at http://twitter.github.io/typeahead.js/data/films/post_1960.json
[
{
"year": "1961",
"value": "West Side Story",
"tokens": [
"West",
"Side",
"Story"
]
},
{
"year": "1962",
"value": "Lawrence of Arabia",
"tokens": [
"Lawrence",
"of",
"Arabia"
]
}, {
"year": "2012",
"value": "Argo",
"tokens": [
"Argo"
]
}
]

Related

Superset API Request Filters

I'm attempting to retreive a list of dashboards via the superset API which have a specific owner. I've attempted many unsuccessful ways to compose the request:
/api/v1/dashboard/?q={
"filters": [
{
"col": "owners__username",
"opr": "eq",
"value": "bi"
}
]
}
Resulted in Filter column: owners__username not allowed to filter
/api/v1/dashboard/?q={
"filters": [
{
"col": "owners",
"opr": "any",
"value": {
"col": "username",
"opr": "eq",
"value": "bi"
}
}
]
}
Result: Not a valid rison schema
/api/v1/dashboard/?q={
"filters": [
{
"col": "owners",
"opr": "any",
"value": "ADMIN0"
}
]
}
Which gives me all results
What am I missing?
Try this:
/api/v1/dashboard/?q=(filters:!((col:owners,opr:rel_m_m,value:4)))
So that filter only accepts user id's
You can get a list of supported filters on each resource by:
/api/v1/dashboard/_info?q=(keys:!(filters))

Passing the value of the select list, to the callback url body on office365 connector card? (payload format)

I'm trying to develop a connector.
I have created the card and the webhook and entered a callback URL to my node.js server for httpost action. I can't get the value of the select list to pass to my server when I click send.
I tried including a body string at the card but then I get
SyntaxError: Unexpected token # in JSON at position 0.
When I send without a body it communicates with my server but I cant get the values. I log the request and there are nowhere.
Below is the a section of the code sample of one office365 connector cards for outlook. It is written in the card reference that the httppost action can contain a body. So i assume this body will be sen to my server with the valu ethat i define. But when i include the body i get the above error and the action doesn't complete as it does without a body.
{
"#type": "ActionCard",
"name": "Move",
"inputs": [
{
"#type": "MultichoiceInput",
"id": "move",
"title": "Pick a list",
"choices": [
{ "display": "List 1", "value": 500 },
{ "display": "List 2", "value": 600 }
]
}
],
"actions": [
{
"#type": "HttpPOST",
"name": "Save",
"target": "https://aptdevserver.westeurope.cloudapp.azure.com/chat/messages/create",
"body": "value",
"bodyContentType": "application/json"
}
]
}
You're not telling Outlook which value you want to send. You need to tell it that you want to do a string replacement, otherwise you are litterally sending the string value in the body of your POST:
"body": "{ \"move\": \"{{move.value}}\" }"
Using your complete example:
{
"#type": "ActionCard",
"name": "Move",
"inputs": [
{
"#type": "MultichoiceInput",
"id": "move",
"title": "Pick a list",
"choices": [
{ "display": "List 1", "value": 500 },
{ "display": "List 2", "value": 600 }
]
}
],
"actions": [
{
"#type": "HttpPOST",
"name": "Save",
"target":
"https://aptdevserver.westeurope.cloudapp.azure.com/chat/messages/create",
"body": "{ \"move\": \"{{move.value}}\" }",
"bodyContentType": "application/json"
}
]
}

Facebook API targeting sentence lines returning Chinese

I am calling the facebook targeting sentence lines with api version 2.7 and getting different results depending on the environment. In staging and development I get:
{
"targetingsentencelines": [
{
"content": "Location - Living In:",
"children": [
"United States: Decatur (+10 mi) Georgia"
]
},
{
"content": "Age:",
"children": [
"18 - 65+"
]
},
{
"content": "Placements:",
"children": [
"News Feed on mobile devices, News Feed on desktop computers or Right column on desktop computers"
]
}
]
}
However in preprod I get:
{
"targetingsentencelines": [
{
"content": "Location - Living In:",
"children": [
"United States: Decatur (+10 mi) Georgia 喬治亞州"
]
},
{
"content": "Age:",
"children": [
"18 - 65+"
]
},
{
"content": "Placements:",
"children": [
"News Feed on mobile devices, News Feed on desktop computers or Right column on desktop computers"
]
}
]
}
Using the Graph Explorer API v2.7 (https://developers.facebook.com/tools/explorer/) and a uri of:
act_FACEBOOK IDENTIFIER/targetingsentencelines?targeting_spec={%22geo_locations%22:{%22cities%22:[{%22key%22:%222431637%22,%22radius%22:%2210%22,%22distance_unit%22:%22mile%22}]},%22age_min%22:%2218%22,%22device_platforms%22:[%22mobile%22,%22desktop%22],%22publisher_platforms%22:[%22facebook%22],%22facebook_positions%22:[%22feed%22,%22right_hand_column%22]}
I get the same results as in staging, and development.
Adding local=en_US does work. I mis-typed it the first time.

Drupal-8 restful webservices only delivering HTML

I have a freshly configured Drupal 8.0 beta 12 with HAL, HTTP Basic Authentication, RESTful Web Services and Serialization modules enabled. The installation is in a subfolder (D8_beta12). When I access the web services for the first page created (id=1) like
curl -H "Accept: application/json" --request GET http://localhost/d8_beta12/node/1
DRUPAL only delivers HTML format of the node. I have tried to configure via REST UI to JSON only but that didn't help. DRUPAL would answer the requests even if the web services are disabled.
Its probably the user, who's sitting in front of DRUPAL, who is the problem (me) - but I don't get it. Any help deply appreciated - I have been working hours on this, reviewing all of DRUPALs forums and here as well.
Thanks,
Andi
I was getting the same and found a note about it https://drupal.stackexchange.com/questions/161421/d8-services-errors-no-route-found-for-the-specified-formats
So I updated the request to :
node/1?_format=json
Update: Found note about it in a webchick slideshare:
http://www.slideshare.net/webchickenator/plain-english-guide-to-drupal-8-criticals/51
Please try replacing aaplication/json with application/hal+json.
curl -H "Accept: application/hal+json" --request GET http://localhost/d8_beta12/node/1
You may also like to go through this precise tutorial.
from postman if you are trying or from other rest api you are trying make sure you follow below format
http://localhost/da/drupal819/node/253?_format=json
output
{
"nid": [
{
"value": "253"
}
],
"uuid": [
{
"value": "6f255c93-6886-4c38-b4cb-c40469073d1c"
}
],
"vid": [
{
"value": "253"
}
],
"langcode": [
{
"value": "en"
}
],
"type": [
{
"target_id": "article",
"target_type": "node_type",
"target_uuid": "ee2c7b5e-d57e-4714-9193-daff153c63ff"
}
],
"title": [
{
"value": "Commodo Pagus Quia"
}
],
"uid": [
{
"target_id": "14",
"target_type": "user",
"target_uuid": "0b8602ec-8003-4e3d-8406-5bd53e47df71",
"url": "/da/drupal819/user/14"
}
],
"status": [
{
"value": "1"
}
],
"created": [
{
"value": "1474126412"
}
],
"changed": [
{
"value": "1474175616"
}
],
"promote": [
{
"value": "1"
}
],
"sticky": [
{
"value": "0"
}
],
"revision_timestamp": [
{
"value": "1474175616"
}
],
"revision_uid": [
{
"target_id": "14",
"target_type": "user",
"target_uuid": "0b8602ec-8003-4e3d-8406-5bd53e47df71",
"url": "/da/drupal819/user/14"
}
],
"revision_log": [],
"revision_translation_affected": [
{
"value": "1"
}
],
"default_langcode": [
{
"value": "1"
}
],
"path": [],
"body": [
{
"value": "Duis revitas melior paulatim quibus quidne rusticus velit vereor.\n\n",
"format": "plain_text",
"summary": "Duis vitas melior paulatim quibus quidne rusticus velit vereor.\n\n"
}
],
"comment": [
{
"status": "2",
"cid": "165",
"last_comment_timestamp": "1474175616",
"last_comment_name": "",
"last_comment_uid": "13",
"comment_count": "1"
}
],
"field_image": [
{
"target_id": "248",
"alt": "Diam iriure neo quadrum refero valetudo verto ymo.",
"title": "Os patria refoveo si valetudo.",
"width": "225",
"height": "526",
"target_type": "file",
"target_uuid": "02050136-7a51-4183-9c28-7d7cc793183a",
"url": "http://localhost/da/drupal819/sites/default/files/2016-09/gen8C.tmp.jpeg"
}
],
"field_tags": []
}
you can try other format as well
1) http://localhost/da/drupal819/node/253?_format=hal_json
2) http://localhost/da/drupal819/node/253?_format=xml
to support all above format you need to make that format support from rest configuration from admin panel
and even you need to provide get permission for rest call from permission page for anonymous user.

list of Page Categories on facebook

I'm developing a facebook search and I would like to list all the page categories (is not relevant but I'm working with koala ruby gem):
A search with type="page" has results like these:
{"category"=>"Community", "name"=>"Koala", "id"=>"7356642860"}
{"category"=>"Product/service", "name"=>"Koala Groupe", "id"=>"188919981197745"}
{"category"=>"Public figure", "name"=>"Cushelle Koala", "id"=>"109202405786555"}
{"category"=>"Dancer", "name"=>"Koala Dance Bots", "id"=>"208563099183596"}
{"category"=>"Musician/band", "name"=>"Kid Koala", "id"=>"17527901121"}
{...}
I'm trying to develop a form to permit the user to achieve a a more precise search.
Then, I would like the user to have a list of categories, but: How to get the facebook pages categories list?
Use the following API to get list of page categories
FB.api(
'/fb_page_categories',
'GET',
{},
function(response) {
// Insert your code here
}
);
You will get response as
{
"data": [
{
"name": "Advertising/Marketing",
"fb_page_categories": [
{
"name": "Advertising Agency",
"id": "164886566892249"
},
{
"name": "Brand Agency",
"id": "1736039333278498"
},
{
"name": "Copywriting Service",
"id": "197029287003787"
},
{
"name": "Digital/Online Marketing Agency",
"id": "1751954525061797"
},
{
"name": "Internet Marketing Service",
"id": "1706730532910578"
},
{
"name": "Marketing Agency",
"id": "123377808095874"
},
{
"name": "Marketing Consultant",
"id": "170992992946914"
},
{
"name": "Media Agency",
"id": "281507032196735"
},
{
"name": "Public Relations Agency",
"id": "192021210817573"
},
{
"name": "Social Media Agency",
"id": "530553733821238"
},
{
"name": "Telemarketing Service",
"id": "197557456921449"
}
],
"id": "1757592557789532"
}
and so on....
There is a similar question here:
Authoritative List of all Facebook Subcategories
that I responded to. Hope this helps.
A standard Graph API call would be:
https://graph.facebook.com/v2.10/fb_page_categories?access_token={access_token_obfuscated}