I am new to freebase. Might be a simple answer but I cant seem to understand the freebase API. I try to run a simple query using the command queryResult = freebase.mqlread(queryFB); and I get the error below. I haven't logged in to the API. I created an account which is a google account. My question is when I call freebase.login(username,password); what do I use? Google account details? I am also attaching my query.
Query:
{
"type": "/food/dish",
"id": dish,
"name": None,
"cuisine":
[{
"id": None,
"name": None,
"region_of_origin":
[{
"id": None,
"name": None,
"/location/location/contains":
[{
"id": None,
"name": city,
"type": "/location/citytown",
"limit": 20
}]
}],
"optional": "optional"
}],
"type_of_dish1":
[{
"id": None,
"name": None,
"optional": "optional"
}]
}
Error:
{
"error":
{
"errors":
[
{
"domain": "usageLimits",
"reason": "userRateLimitExceededUnreg",
"message": "User Rate Limit Exceeded. Please sign up",
"extendedHelp": "https://code.google.com/apis/console"
}
],
"code": 403,
"message": "User Rate Limit Exceeded. Please sign up"
}
}
Sounds like you might be using an obsolete client library and/or API. The current API doesn't use a username/password pair, but rather an API key.
Try this. It will explain how to use api key for running MQL. You will need to get only the apikey for freebase. NO username or password is required.
https://developers.google.com/freebase/v1/mql-overview
Related
I want to create two telegram bots on one adress https://example.com
this is working with webhooks, but i can't identify from which bot request came.
This is what i recieve from bot 1:
{
"update_id": 610779399,
"message": {
"message_id": 58,
"from": {
"id": 299470913,
"is_bot": false,
"first_name": "my_first_name",
"last_name": "my_last_name",
"username": "my_user_name",
"language_code": "en"
},
"chat": {
"id": 299470913,
"first_name": "my_first_name",
"last_name": "my_last_name",
"username": "my_user_name",
"type": "private"
},
"date": 1664720338,
"text": "this message is from bot 1"
}
}
This is what i recieve from Bot 2:
{
"update_id": 66917787,
"message": {
"message_id": 37910,
"from": {
"id": 299470913,
"is_bot": false,
"first_name": "my_first_name",
"last_name": "my_last_name",
"username": "my_user_name",
"language_code": "en"
},
"chat": {
"id": 299470913,
"first_name": "my_first_name",
"last_name": "my_last_name",
"username": "my_user_name",
"type": "private"
},
"date": 1664720333,
"text": "this is from bot 2"
}
}
Responses looks identical, is it even possible to identify from which bot request came?
When setting up the webhook using setWebhook API method, you can set secret_token parameter, which will specify value of X-Telegram-Bot-Api-Secret-Token header in every request sent to your webhook.
Secret token is usually used for security purposes, to make sure that the requests sent to your webhook are really coming from Telegram (and not from some malicious actor). If you use different secret tokens for two different bots, you can also use these tokens to specify from which bot the request was sent.
I am trying to create a Python program to get channel statisitics, but when I run it the YouTube API website gives this output (error):
{
"error": {
"code": 400,
"message": "'statisitcs'",
"errors": [
{
"message": "'statisitcs'",
"domain": "youtube.part",
"reason": "unknownPart",
"location": "part",
"locationType": "parameter"
}
]
}
}
This is my code:
class YTstats:
def __init__(self, api_key, channel_id):
self.api_key = api_key
self.channel_id = channel_id
self.channel_stats = None
def get_channel_statistics(self):
url = f'https://www.googleapis.com/youtube/v3/channels?part=statisitcs&id={self.channel_id}&key={self.api_key}'
print(url)
API_KEY = 'I cannot share my api key so I am not showing it but it is in my code'
yt = YTstats(API_KEY, 'UCbXgNpp0jedKWcQiULLbDTA')
yt.get_channel_statistics()
This problem is fixed now (it was a typo)
You have a typo here part=statisitcs - as you mentioned in your comment - and after looking closely to the code you provided in your question.
Next time, check closely your code and try to replicate the error using the try-it demo feature in the YouTube Data API documentation.
I do get the statistics of the channel_id you provided - that is: UCbXgNpp0jedKWcQiULLbDTA:
These are their statistics:
"statistics": {
"viewCount": "5642720",
"subscriberCount": "98400",
"hiddenSubscriberCount": false,
"videoCount": "158"
}
}
See the demo here.
Here is the full response:
{
"kind": "youtube#channelListResponse",
"etag": "lG-nYlbLnN81gtjVKe1zKPW6v7A",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#channel",
"etag": "j4Fo8qKbWrLHnQYB8sCI8_I4v9A",
"id": "UCbXgNpp0jedKWcQiULLbDTA",
"snippet": {
"title": "Python Engineer",
"description": "Free Python and Machine Learning Tutorials!\n\nHi, I'm Patrick. I’m a passionate Software Engineer who loves Machine Learning, Computer Vision, and Data Science. I create free content in order to help more people get into those fields. If you have any questions, feedback, or comments, just shoot me a message! I am happy to talk to you :)\n\nIf you like my content, please subscribe to the channel!\n\nPlease check out my website for more information:\nhttps://www.python-engineer.com\n\nIf you find these videos useful and would like to support my work you can find me on Patreon:\nhttps://www.patreon.com/patrickloeber\n\nLegal: https://www.python-engineer.com/legal-notice/\n",
"customUrl": "pythonengineer",
"publishedAt": "2019-05-03T11:22:33Z",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AKedOLTs-Pvd4mvUi-m2rDLd8bzrKwS5a8C9HnDbkUDzHw=s88-c-k-c0x00ffffff-no-rj",
"width": 88,
"height": 88
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AKedOLTs-Pvd4mvUi-m2rDLd8bzrKwS5a8C9HnDbkUDzHw=s240-c-k-c0x00ffffff-no-rj",
"width": 240,
"height": 240
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AKedOLTs-Pvd4mvUi-m2rDLd8bzrKwS5a8C9HnDbkUDzHw=s800-c-k-c0x00ffffff-no-rj",
"width": 800,
"height": 800
}
},
"localized": {
"title": "Python Engineer",
"description": "Free Python and Machine Learning Tutorials!\n\nHi, I'm Patrick. I’m a passionate Software Engineer who loves Machine Learning, Computer Vision, and Data Science. I create free content in order to help more people get into those fields. If you have any questions, feedback, or comments, just shoot me a message! I am happy to talk to you :)\n\nIf you like my content, please subscribe to the channel!\n\nPlease check out my website for more information:\nhttps://www.python-engineer.com\n\nIf you find these videos useful and would like to support my work you can find me on Patreon:\nhttps://www.patreon.com/patrickloeber\n\nLegal: https://www.python-engineer.com/legal-notice/\n"
}
},
"contentDetails": {
"relatedPlaylists": {
"likes": "",
"uploads": "UUbXgNpp0jedKWcQiULLbDTA"
}
},
"statistics": {
"viewCount": "5642720",
"subscriberCount": "98400",
"hiddenSubscriberCount": false,
"videoCount": "158"
}
}
]
}
Try to wait a few minutes after the call you made - probably, the API couldn't retrieve the data you requested due to excessive requests or the channel itself didn't have their statistics publicly available.
I'm working on an Alexa skill using the Alexa Skills Kit, and when the user says an invalid utterance, it replies with 'There was a problem with the requested skill's response'.
I've tried using the AMAZON.Fallback intent, but looking at the json output in the test window shows that it hasn't been triggered.
My backend is python 2.7 in Lambda and I'm using the locale en-gb (I've tried copying the interaction model into en-us but had the same results).
Is fallback intent the right thing to use to handle invalid utterances, or is there another way to achieve similar results?
Here is the Json input:
{
"version": "1.0",
"session": {
"new": false,
"sessionId": "amzn1.echo-api.session.bb6cd858-2128-44d2-8c43-ed6c501e0be4",
"application": {
"applicationId": "amzn1.ask.skill.0fbcbd10-17ee-49ea-9f7a-30401dc26a56"
},
"user": {
"userId": "amzn1.ask.account.AHL5Q4YLTSH3CHSILRWTE6FBK3XLKFE3XR6D6KY45IW6QVKJOW6ZWUAWMVS23YRY6EVWM45DKXPJSOXFP5AJ47TJTFD3JRHGEMUVAMKVZ4GGFJZ35JGAJV22RRDKP534OKVE46QPI32H5T6IJFHDVPP4TC3W6QXDJ2XPTYUL3U2MLQ2NYSG63UE2Q3MJZGJ7GEA5MIKSJCWUPEQ"
}
},
"context": {
"System": {
"application": {
"applicationId": "amzn1.ask.skill.0fbcbd10-17ee-49ea-9f7a-30401dc26a56"
},
"user": {
"userId": "amzn1.ask.account.AHL5Q4YLTSH3CHSILRWTE6FBK3XLKFE3XR6D6KY45IW6QVKJOW6ZWUAWMVS23YRY6EVWM45DKXPJSOXFP5AJ47TJTFD3JRHGEMUVAMKVZ4GGFJZ35JGAJV22RRDKP534OKVE46QPI32H5T6IJFHDVPP4TC3W6QXDJ2XPTYUL3U2MLQ2NYSG63UE2Q3MJZGJ7GEA5MIKSJCWUPEQ"
},
"device": {
"deviceId": "amzn1.ask.device.AGBUICDG5CR3PRTAM43NOEG3QDWUIIPF723CFMXHZILFXJY4CNAUNFVQGH33BL6VRU4DXG667KBEIE66XIO4ZW44DL2O67ALKIJDVV2YF7JPPAZAUZRGI2EHH34KVEHSPZRM3TMLPIAREL4LSTWFSI3MU2JA",
"supportedInterfaces": {}
},
"apiEndpoint": "https://api.eu.amazonal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QQivM8_juK-hX_9FqDgYrnNmUz3erehtd7P_Euf9uiMXQgN5uF1NCwh0GscxnD_XPQ6b98I3hJnze-OHIFfEkla1THH180Op6O4Q47vlMHZWgl4cDQJneATUSOcHXOq8NnN9vfP_z2Q33g7n3BJmPvz-6vWsgbSrEajX-3xHs8rjIcdxvnc-w"
},
"Viewport": {
"experiences": [
{
"arcMinuteWidth": 246,
"arcMinuteHeight": 144,
"canRotate": false,
"canResize": false
}
],
"shape": "RECTANGLE",
"pixelWidth": 1024,
"pixelHeight": 600,
"dpi": 160,
"currentPixelWidth": 1024,
"currentPixelHeight": 600,
"touch": [
"SINGLE"
]
}
},
"request": {
"type": "SessionEndedRequest",
"requestId": "amzn1.echo-api.request.33d7948c-e4de-4ec9-9490-8e66c460d8f7",
"timestamp": "2019-02-19T17:33:18Z",
"locale": "en-GB",
"reason": "ERROR",
"error": {
"type": "INVALID_RESPONSE",
"message": "Invalid SSML Output Speech for requestId amzn1.echo-api.request.14165ddf-86dc-4cd2-b636-94df1ddfd835. Error: Fatal error occurred when processing SSML content. This usually happens when the SSML is not well formed. Error: Unexpected character 'T' (code 84) in prolog; expected '<'\n at [row,col {unknown-source}]: [1,1]"
}
}
}
If you're working with a skill that in English or German yes, you should use fallback intent. Other locales do not support it yet.
For en-GB or en-US you need to make sure that AMAZON.FallbackIntent is defined in your voice interaction model (front-end) and that you have an handler in the back-end (eg lambda) to catch intent requests named AMAZON.FallbackIntent
This definitely sound like a problem in your backen-end processiong the fallback intent (you might not be catching it properly)
I would like to add a share button for social media. I've got the Slack workflow buttons working, but I'd like those receiving the message payload to be able to share what they're receiving. Here's what I've got so far.
def post_summary_to_slack(self):
data = str(
{'text': self.summary_printout,
'attachments': [
{
"fallback": "Was this a good use of time and money?",
"title": "Was this a good use of time and money?",
"callback_id": "meetings_survey",
"color": "#800080",
"attachment_type": "default",
"actions": [
{
"name": "yes",
"text": "Yes",
"type": "button",
"value": "yes"
},
{
"name": "no",
"text": "No",
"type": "button",
"value": "no"
},
{
"name": "maybe",
"text": "I'm Not Sure",
"type": "button",
"value": "maybe"
},
/* maybe here:*/
{
"name": "twitter",
"text": "Tweet",
"type": "button",
"value": "Here are the results from the latest analysis"
}
]
}
]
}
)
url = self.SLACK_HOOK
req = urllib2.Request(url, data, {'Content-Type': 'application/json'})
f = urllib2.urlopen(req)
f.close()
Has anybody tried something like this? Thanks for the help!
Sure you can do that. However, Slack does not provide a Twitter share button out-of-the-box, so your script will need to implement that functionality. So your Twitter share button will call your script (like any other message button) and your script will need to forward the message contents to Twitter by calling the correct Twitter APIs etc.
This is my first time with paypal and I need some help to finish payment integration. I've already tried to contact the paypal support but with no success. Here is my question and I really hope to get some help.
Something very strange grinds my gears and I cannot find why this do that. It's about the user authorization, and specially about paypal json responses. I'm using python sdk but that doesn't matter in this case. Here is my input.
paypalrestsdk.configure({
'mode': 'sandbox',
'client_id': 'XXX',
'client_secret': 'XXX'
})
payment = paypalrestsdk.Payment({
"intent": "authorize",
"payer": {
"payment_method": "paypal"
},
"redirect_urls": {
"return_url": "http://mysite/success",
"cancel_url": "http://mysite/cancel"
},
"transactions": [ {
"amount": {
"total": price,
"currency": "USD"
},
"description": title
}]
})
And everything is ОК, except that I doesn't receive an Authorization ID. Here is what I receive as response:
{
'redirect_urls':{
'cancel_url':'http://glamfame.com:8000/cancel',
'return_url':'http://glamfame.com:8000/success'
},
'update_time':'2014-04-08T13:54:22Z',
'state':'created',
'transactions':[
{
'amount':{
'currency':'USD',
'total':'123.00',
'details':{
'subtotal':'123.00'
}
},
'description':'fawfwa',
'related_resources':[{
'authorization':{
'valid_until':'2014-05-07T13:54:22Z',
'update_time':'2014-04-08T13:54:22Z',
'parent_payment':'PAY-54Y91315F8620142DKNB77DQ',
'create_time':'2014-04-08T13:54:22Z',
'links':[{
'method':'GET',
[link removed]
'rel':'parent_payment'
}]
}
}]
}],
'payer':{
'payer_info':{
'shipping_address':{
}
},
'payment_method':'paypal'
},
'id':'PAY-54Y91315F8620142DKNB77DQ',
'intent':'authorize',
'create_time':'2014-04-08T13:54:22Z',
'links':[{ POST, GET, REDIRECT methods with links
}]
And below is what I supposed to receive according their documentation.
{
"id": "2DC87612EK520411B",
"create_time": "2013-06-25T21:39:15Z",
"update_time": "2013-06-25T21:39:17Z",
"state": "authorized",
"amount": {
"total": "7.47",
"currency": "USD",
"details": {
"subtotal": "7.47"
}
},
"parent_payment": "PAY-36246664YD343335CKHFA4AY",
"valid_until": "2013-07-24T21:39:15Z",
"links": [
{
"href": [link removed]
"rel": "self",
"method": "GET"
},
{
"href": [link removed]
"rel": "capture",
"method": "POST"
},
{
"href": [link removed]
"rel": "void",
"method": "POST"
},
{
"href": [link removed]
"rel": "parent_payment",
"method": "GET"
}]
}
As you maybe already noticed, in the paypal response doesn't contain authorization id and void, and capture link. Can you please help me to find out the reason for this. Thank you in advance.
Best Regards,
Georgi
From the REST API documentation: With PayPal payments authorizations, PayPal initially provides HATEOAS links that are specific to PayPal payments including an approval_url and execute link. First get payment approval and execute the payment as you normally would do for a PayPal payment. Once you successfully execute on the payment authorization, PayPal responds with a new set of HATEOAS links, including a capture link that you use to capture the payment.