missing urls in "entities" key in Twitter API v2 - twitter-api-v2

I am trying to extract urls in tweets via Twitter API v2.
'tweet.fields': 'entities,geo,id,in_reply_to_user_id,lang,public_metrics,possibly_sensitive,referenced_tweets,reply_settings,source,text,withheld'
In some twitter accounts, responses contain "entities" key and "urls". For example:
{"entities": {"hashtags": [{"start": 0, "end": 4, "tag": "Son"}], "urls": [{"start": 141, "end": 164, "url": "https: //t. co/3Oz5CTg4xO", "expanded_url": "https://www.tgrthaber.com.tr/politika/son-dakika-ak-parti-sozcusu-omer-celikten-onemli-aciklamalar-2831218", "display_url": "tgrthaber.com.tr/politika/son-d\u2026"}, {"start": 165, "end": 188, "url": "https://t. co/ aYZaOnv67V", "expanded_url": "https://twitter.com/tgrthabertv/status/1533107361853890560/photo/1", "display_url": "pic.twitter.com/ aYZaOnv67V", "media_key": "3_1533107330765754368"}]}, "text": "#Son dakika MUHALEFET\u0130N 'SE\u00c7\u0130M G\u00dcVENL\u0130\u011e\u0130' ELE\u015eT\u0130R\u0130S\u0130\n\nAK Parti S\u00f6zc\u00fcs\u00fc \u00c7elik: Kaybedecekleri se\u00e7ime \u015fimdiden bahane uydurmaya \u00e7al\u0131\u015f\u0131yorlar\n\nhttps: //t. co/3Oz5CTg4xO https://t. co/ aYZaOnv67V", "public_metrics": {"retweet_count": 1, "reply_count": 0, "like_count": 5, "quote_count": 0}, "source": "TweetDeck", "possibly_sensitive": false, "id": "1533107361853890560", "created_at": "2022-06-04T15:24:13.000Z", "attachments": {"media_keys": ["3_1533107330765754368"]}, "reply_settings": "everyone", "author_id": "234419133", "conversation_id": "1533107361853890560", "lang": "tr"}
HOWEVER, from some twitter accounts, NO URLS RETURNED even if tweets have urls in texts in Twitter. For example;
{"created_at": "2022-06-20T15:42:56.000Z", "public_metrics": {"retweet_count": 3, "reply_count": 0, "like_count": 0, "quote_count": 0}, "id": "1538910278590550016", "text": "RT #odatv: Ba\u015fkana 4 y\u0131l hapis istemi", "possibly_sensitive": false, "entities": {"mentions": [{"start": 3, "end": 9, "username": "odatv", "id": "63110096"}]}, "source": "Twitter Web App", "author_id": "63110096", "lang": "tr", "referenced_tweets": [{"type": "retweeted", "id": "1538847289455812608"}], "conversation_id": "1538910278590550016", "reply_settings": "everyone"}
Why does this happen? Anybody experienced this?

Related

Turn-by-turn latitude and longitude on HERE Routing API

I want to get the latitude and longitude per instruction on the actions I get from HERE Routing API v8. I get the maneuvers from HERE Routing v7 but not on v8. I tried all the return values.
https://router.hereapi.com/v8/routes?apikey=APIKEY&origin=14.57755,121.04239&destination=14.57735,121.04274&return=polyline,summary,actions,instructions&spans=segmentId&transportMode=car
{
"routes": [{
"id": "bae447cc-a31f-48f7-83a7-2c73c34d492d",
"sections": [{
"id": "152087e3-7f61-451e-b764-e88583586f10",
"type": "vehicle",
"actions": [{
"action": "depart",
"duration": 10,
"length": 76,
"instruction": "Head toward Camiguin on Barangka Dr. Go for 76 m.",
"offset": 0
},
{
"action": "continue",
"duration": 22,
"length": 102,
"instruction": "Continue on 9 de Febrero toward Ortigas Ave/Shaw Blvd. Go for 102 m.",
"offset": 3
},
{
"action": "turn",
"duration": 12,
"length": 53,
"instruction": "Turn right onto Talumpong. Go for 53 m.",
"offset": 7,
"direction": "right",
"severity": "quite"
},
{
"action": "turn",
"duration": 29,
"length": 149,
"instruction": "Turn right onto Tabayog. Go for 149 m.",
"offset": 8,
"direction": "right",
"severity": "quite"
},
{
"action": "arrive",
"duration": 0,
"length": 0,
"instruction": "Arrive at Tabayog. Your destination is on the left.",
"offset": 13
}
],
"departure": {
"time": "2022-02-03T18:59:50+08:00",
"place": {
"type": "place",
"location": {
"lat": 14.5775706,
"lng": 121.0423584
},
"originalLocation": {
"lat": 14.5775499,
"lng": 121.04239
}
}
},
"arrival": {
"time": "2022-02-03T19:01:03+08:00",
"place": {
"type": "place",
"location": {
"lat": 14.5773811,
"lng": 121.0426889
},
"originalLocation": {
"lat": 14.5773499,
"lng": 121.04274
}
}
},
"summary": {
"duration": 73,
"length": 380,
"baseDuration": 65
},
"polyline": "BGm635bs767mHiS0MsEkD8L0KgF0FsEoGgF4IoQsdvb8L3IvRnQze3IvHzK3I9ElD",
"spans": [{
"offset": 0,
"topologySegmentId": "+here:cm:segment:46864687"
},
{
"offset": 3,
"topologySegmentId": "+here:cm:segment:47392105"
},
{
"offset": 7,
"topologySegmentId": "-here:cm:segment:26196228"
},
{
"offset": 8,
"topologySegmentId": "-here:cm:segment:23767715"
},
{
"offset": 10,
"topologySegmentId": "-here:cm:segment:21101714"
}
],
"language": "en-us",
"transport": {
"mode": "car"
}
}],
}],
}
As of 2nd day of February 2022, the position paremeter that outputs latitude and longitude in v7 is not supported in v8 under maneuverAttributes. Source
That is correct in routing V8, there is an offset into polyline in maneuver. Offset is the index into the polyline and all coordinates in V8 work this way. spans, actions, they have offset into the route shape which is an array of coordinates. Example: https://demo.routing.ext.here.com/#url=https://router.hereapi.com/v8/routes?apikey=DEFAULT_API_KEY&origin=52.551325,13.351349&destination=52.514255,13.34929&return=polyline,summary,actions,instructions&transportMode=car

Vega-Lite - Is it possible to have the same selector for two different plots?

I've created a plot using Vega-Lite that allows me to use a binder to alter the parameters of a functions that I'm visualizing. It's similar to this sample code:
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Plots two functions using a generated sequence.",
"width": 300,
"height": 150,
"data": {"sequence": {"start": 0, "stop": 12.7, "step": 0.1, "as": "x"}},
"transform": [
{"calculate": "amp.sin * sin(datum.x)", "as": "sin(x)"},
{"calculate": "amp.cos * cos(datum.x)", "as": "cos(x)"},
{"fold": ["sin(x)", "cos(x)"]}
],
"mark": "line",
"encoding": {
"x": {"type": "quantitative", "field": "x"},
"y": {"field": "value", "type": "quantitative"},
"color": {"field": "key", "type": "nominal", "title": null}
},
"selection": {
"amp": {
"type": "single",
"fields": ["sin", "cos"],
"init": {"sin": 1, "cos": 1},
"bind": {
"sin": {"input": "range", "min": 0, "max": 10, "step": 0.1},
"cos": {"input": "range", "min": 0, "max": 10, "step": 0.1}
}
}
}
}
Here is the code above in the Vega editor.
Now, what I'd like to do is to create another visualization parallel to this one, but with another function, but that would also vary with the same binder.
Is this possible? Note that in my code, each plot uses a different dataset, but share the variable of the binder in common.
Yes, for example you can do this using a "concat". Here is an example based on your chart (open in editor):
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Plots two functions using a generated sequence.",
"data": {"sequence": {"start": 0, "stop": 12.7, "step": 0.1, "as": "x"}},
"concat": [
{
"width": 300,
"height": 150,
"transform": [
{"calculate": "amp.sin * sin(datum.x)", "as": "sin(x)"},
{"calculate": "amp.cos * cos(datum.x)", "as": "cos(x)"},
{"fold": ["sin(x)", "cos(x)"]}
],
"mark": "line",
"encoding": {
"x": {"type": "quantitative", "field": "x"},
"y": {"field": "value", "type": "quantitative"},
"color": {"field": "key", "type": "nominal", "title": null}
},
"selection": {
"amp": {
"type": "single",
"fields": ["sin", "cos"],
"init": {"sin": 1, "cos": 1},
"bind": {
"sin": {"input": "range", "min": 0, "max": 10, "step": 0.1},
"cos": {"input": "range", "min": 0, "max": 10, "step": 0.1}
}
}
}
},
{
"width": 300,
"height": 150,
"transform": [
{
"calculate": "amp.cos * cos(datum.x) - amp.sin * sin(datum.x)",
"as": "cos(x) - sin(x)"
}
],
"mark": "line",
"encoding": {
"x": {"type": "quantitative", "field": "x"},
"y": {"field": "cos(x) - sin(x)", "type": "quantitative"}
}
}
],
"resolve": {"scale": {"y": "shared", "color": "independent"}}
}

Label ACF 'repeater' doesn't work anymore since update WordPress and ACF plugin

I have updated my WordPress from 4.6.x to 5.2.1.
I have also updated plugin ACF Pro from 4.x.x to 5.8.1.
Since then, ACF labels of type 'repeater' doesn't work anymore :
they don't appear anymore in admin panel and in front of application.
The other labels work well.
I don't know why. Do you have an idea ?
{
"key": "field_56f04b4f1d998",
"label": "Layouts",
"name": "layouts",
"type": "repeater",
"instructions": "",
"required": 0,
"conditional_logic": [],
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"collapsed": "",
"min": "",
"max": "",
"layout": "block",
"button_label": "Add layout",
"sub_fields": [
{
"key": "field_573c2f5d67d89",
"label": "Type",
"name": "type",
"type": "select",
"instructions": "",
"required": 1,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"choices": {
"layout100": "1\/1",
"layout100_full": "1\/1 full",
"layout5050": "1\/2 + 1\/2",
"layout3366": "1\/3 + 2\/3",
"layout6633": "2\/3 + 1\/3"
},
"default_value": [
0
],
"allow_null": 0,
"multiple": 0,
"ui": 0,
"ajax": 0,
"return_format": "value",
"placeholder": ""
},
{
"key": "field_5a266ce145c75",
"label": "Border top ?",
"name": "border_top",
"type": "true_false",
"instructions": "",
"required": 0,
"conditional_logic": 0,
"wrapper": {
"width": "",
"class": "",
"id": ""
},
"message": "",
"default_value": 1
}
]
}
Update acf-component-field plugin and add 'field_group_key=component_group_id' in your json.

Unable to transcode telegram voice message using IBM Watsown Speech to Text with Node-Red

Trying to transcript audio from Telegram voice message but I got "unable to transcode data stream audio/opus -> audio/x-float-array" error from watson's speech to text node.
I'm using Node-Red on Raspberry to simply transcript audio from Telegram voice message with node-red-contrib-telegrambot and node-red-node-watson.
With text messages, my code works as a charm.
With Voice Messages, I got "unable to transcode data stream audio/opus -> audio/x-float-array" error from watson's speech to text node.
node-red flow images I don't have enough reputation point to post images :(
JSON flow export
[
{
"id": "b4106ec1.63dd58",
"type": "tab",
"label": "Telegram",
"disabled": false,
"info": ""
},
{
"id": "d1198164.e38f68",
"type": "telegram receiver",
"z": "b4106ec1.63dd58",
"name": "FMWatsonBot",
"bot": "5f347711.7876d8",
"saveDataDir": "",
"x": 110,
"y": 100,
"wires": [
[
"f4b4ab25.5dde18",
"f5d126df.5b6928"
],
[]
]
},
{
"id": "c6ec445d.0840d8",
"type": "telegram sender",
"z": "b4106ec1.63dd58",
"name": "Send2Telegram",
"bot": "5f347711.7876d8",
"x": 780,
"y": 80,
"wires": [
[]
]
},
{
"id": "f4b4ab25.5dde18",
"type": "debug",
"z": "b4106ec1.63dd58",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 290,
"y": 60,
"wires": []
},
{
"id": "f5d126df.5b6928",
"type": "function",
"z": "b4106ec1.63dd58",
"name": "Save chat context",
"func": "msg.chatId = msg.payload.chatId;\nmsg.type = msg.payload.type;\nmsg.content = msg.payload.content;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 230,
"y": 160,
"wires": [
[
"c3d1a92d.227568"
]
]
},
{
"id": "276cfad7.cef62e",
"type": "function",
"z": "b4106ec1.63dd58",
"name": "Set Chat Context",
"func": "msg.payload = {\n chatId : msg.chatId,\n topic : msg.type,\n type : \"message\",\n content : msg.payload};\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 730,
"y": 220,
"wires": [
[
"c6ec445d.0840d8"
]
]
},
{
"id": "c3d1a92d.227568",
"type": "switch",
"z": "b4106ec1.63dd58",
"name": "Check msg type",
"property": "type",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "message",
"vt": "str"
},
{
"t": "eq",
"v": "voice",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 300,
"y": 240,
"wires": [
[
"e8452a44.f967c8"
],
[
"6aea6224.578d8c"
],
[]
]
},
{
"id": "e8452a44.f967c8",
"type": "function",
"z": "b4106ec1.63dd58",
"name": "Echo message",
"func": "msg.payload = {\n chatId : msg.chatId,\n topic : \"Text Echo\",\n type : msg.type,\n content : msg.content};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 540,
"y": 80,
"wires": [
[
"c6ec445d.0840d8"
]
]
},
{
"id": "6aea6224.578d8c",
"type": "change",
"z": "b4106ec1.63dd58",
"name": "Set voice URL",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.weblink",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 440,
"y": 300,
"wires": [
[
"fc7b1590.557c"
]
]
},
{
"id": "493d1bac.216d3c",
"type": "change",
"z": "b4106ec1.63dd58",
"name": "Set transcription",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "transcription",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 680,
"y": 300,
"wires": [
[
"276cfad7.cef62e"
]
]
},
{
"id": "fc7b1590.557c",
"type": "watson-speech-to-text",
"z": "b4106ec1.63dd58",
"name": "S2T",
"alternatives": 1,
"speakerlabels": false,
"smartformatting": false,
"lang": "en-GB",
"langhidden": "en-GB",
"langcustom": "NoCustomisationSetting",
"langcustomhidden": "",
"custom-weight": "0.5",
"band": "BroadbandModel",
"bandhidden": "BroadbandModel",
"keywords": "",
"keywords-threshold": "0.5",
"word-confidence": false,
"password": "",
"apikey": "#########CHANGED VALUE TO POST###########",
"payload-response": false,
"streaming-mode": false,
"streaming-mute": true,
"auto-connect": false,
"discard-listening": false,
"disable-precheck": false,
"default-endpoint": true,
"service-endpoint": "https://stream.watsonplatform.net/speech-to-text/api",
"x": 530,
"y": 360,
"wires": [
[
"493d1bac.216d3c"
]
]
},
{
"id": "5f347711.7876d8",
"type": "telegram bot",
"z": "",
"botname": "FMWatsonBot",
"usernames": "",
"chatids": "",
"baseapiurl": "",
"updatemode": "polling",
"pollinterval": "300",
"bothost": "",
"localbotport": "8443",
"publicbotport": "8443",
"privatekey": "",
"certificate": "",
"verboselogging": false
}
]
Any hint?
Thanks in advance
Ferruccio
It boils down to how you are fetching the audio from Telegram. Check the answer to this related question - https://developer.ibm.com/answers/questions/424777/help-how-do-i-use-speech-to-text-with-my-telegram/
which shows how to build the url to send through to the Speech to text node.
Update: Flow perfectly works with telegram node v4.4.0, but fails with new version 5.1.5
So, it's not a problem regarding Speech to Text node.

How to create GTM variable from dataLayer array?

I have no problems creating GTM variables from 'simple' dataLayer,
example:
"transactionEntity": "ORDER",
"transactionId": "193552702",
But can't understand how to take values from array.
Basically i need to take ID value from these dataLayer table:
"transactionProducts": [
{
"id": "5",
"sku": "black-handbag",
"price": 170,
"priceexcludingtax": "0.00",
"tax": "0.00",
"taxrate": 0,
"type": "bundle",
"category": "",
"quantity": 1
},
{
"id": "3",
"sku": "red-handbag",
"price": 120,
"priceexcludingtax": "0.00",
"tax": "0.00",
"taxrate": 0,
"type": "bundle",
"category": "",
"quantity": 1
}
],
And to pass them to FB pixel using this format:
content_ids: ['5', '3'],
If you have datalayer like that:
<script>
dataLayer.push({
'ecommerce': {
"transactionProducts": [
{
"id": "5",
"sku": "black-handbag",
"price": 170,
"priceexcludingtax": "0.00",
"tax": "0.00",
"taxrate": 0,
"type": "bundle",
"category": "",
"quantity": 1
},
{
"id": "3",
"sku": "red-handbag",
"price": 120,
"priceexcludingtax": "0.00",
"tax": "0.00",
"taxrate": 0,
"type": "bundle",
"category": "",
"quantity": 1
}
]
}
});
</script>
And you want to create variable which will return array of IDs ['5', '3']
Then you need to create two variables:
1) Name: transactionProducts
Type: Data Layer Variable
Data Layer Variable Name: ecommerce.transactionProducts
2) Name: transactionProductsIds
Type: Custom JavaScript
Custom JavaScript: function () { return {{transactionProducts}}.map(function(a) {return a.id;}); }
And then you can use your second variable transactionProductsIds to receive IDs

Resources