How to send telegram message to a topic thread? - telegram

Recently Telegram added support for Topics in Groups in Bot API version 6.3 and this support added into python-telegram-bot version 13.15 (please find changelog https://docs.python-telegram-bot.org/en/stable/changelog.html)
Im sending messages like this:
{
"#type": "sendMessage",
"chat_id": "-1001580394181",
"input_message_content": {
"#type": "inputMessageText","text": {
"#type": "formattedText","text": "test", "entities": []
}
}
}
and it works. They added message_thread_id parameter to define to which topic message should be sent. So i added the parameter:
{
"#type": "sendMessage",
"chat_id": "-1001580394181",
"message_thread_id": "20451426304",
"input_message_content": {
"#type": "inputMessageText","text": {
"#type": "formattedText","text": "test", "entities": []
}
}
but message goes to main topic, there's no error or anything unless i'll provide incorrect message_thread_id, if so i'm getting message: Code: 400, message: Invalid message thread ID specified
What i'm doing wrong? The id's are correct i got them from catching the response from sending test message to topic channel.

Related

Creatives LinkedIn API - Projection parameters not supported with new versioned API

`Hi All,
After LinkedIn API versioning, it seems that below projection parameter is not supported with creatives API call now :
com.linkedin.ads.SponsoredVideoCreativeVariables
com.linkedin.ads.SponsoredUpdateCarouselCreativeVariables
com.linkedin.ads.SpotlightCreativeVariablesV2
com.linkedin.ads.SponsoredUpdateCreativeVariables
com.linkedin.ads.JobsCreativeVariablesV2
com.linkedin.ads.SponsoredInMailCreativeVariables
Due to this, we are not able to fetch response similar to Old API call with new API now. This seems to be big impact to us.
For example , We are not receiving any of fields like 'showMemberProfilePhoto', 'forumName' for SpotlightCreativeVariablesV2 with new API which we used to get previously like mentioned below.
We have 2 headers in request as mentioned in LinkedIn API migration document.
X-Restli-Protocol-Version : 2.0.0
LinkedIn-Version : 202210
Old API call : https://api.linkedin.com/v2/adCreativesV2?ids=List({$creative_id})&projection=(results(*(variables(*,data(*,com.linkedin.ads.SpotlightCreativeVariablesV2(*,share~(*)))))))
Old API Response :
{
"results": {
"46524875": {
"variables": {
"clickUri": "$clickUri",
"data": {
"com.linkedin.ads.SpotlightCreativeVariablesV2": {
"showMemberProfilePhoto": true,
"forumName": "$forumName",
"description": "$description",
"logo": "$logo",
"headline": "$headline",
"callToAction": "$callToAction"
}
}
}
}
}
}
New API Call : https://api.linkedin.com/rest/creatives?ids=List(urn%3Ali%3AsponsoredCreative%3A{$creative_id})
New API Response :
{
"results": {
"urn:li:sponsoredCreative:$creative_id": {
"servingHoldReasons": ["$servingHoldReasons"],
"lastModifiedAt": 12345678000,
"lastModifiedBy": "",
"content": {
"reference": "urn:li:ugcPost:$ugc_post"
},
"createdAt": 1234562340000,
"isTest": false,
"createdBy": "$createdBy",
"review": {
"status": "APPROVED"
},
"isServing": false,
"campaign": "urn:li:sponsoredCampaign:$campaign_id",
"id": "urn:li:sponsoredCreative:$creative_id",
"intendedStatus": "ACTIVE",
"account": "urn:li:sponsoredAccount:$account_id"
}
},
"statuses": {
"urn:li:sponsoredCreative:creative_id": 200
},
"errors": {}
}
Is there any way to get all those fields we used to get in old API call with new API as we need these fields for processing.
`

Google Analytics API - bad request for Ecommerce activity

I am running the following for our GA reporting v4 API - it works fine without the Ecommerce portion but once I add "ecommerce", it gave me an error.
def get_client_report(analytics):
return analytics.userActivity().search(
body=
{
"viewId": VIEW_ID,
"user": {
"type": "CLIENT_ID",
"userId": "REDACTED"
},
"activityTypes": [
"ECOMMERCE"
],
"dateRange": {
"startDate": "2020-04-02",
"endDate": "2020-04-02"
},
"ecommerce": {
"transaction": {
"transactionId" : "REDACTED"
}
}
}
).execute()
and I get the following error:
https://analyticsreporting.googleapis.com/v4/userActivity:search?alt=json returned "Invalid JSON payload received. Unknown name "ecommerce": Cannot find field.". Details: "[{'#type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'description': 'Invalid JSON payload received. Unknown name "ecommerce": Cannot find field.'}]}]">
Can you help me what is wrong here? Thank you!
your request body doesn't match the expected format. Take a closer look at docs.
only activityTypes field is supported and you cannot filter for a specific transactions ID. you'll have to perform filtering on your side after receiving a response in that case.

Graph API Create new Group and Team - 'Invalid bind property name members in request' issue in Graph Explorer

I am trying to create a new group and team via the Graph API. I am trying to run the POST a request in Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer) as below but get a bad request.
Request: POST
Version: v1.0
URL: https://graph.microsoft.com/v1.0/teams/groups
Request Body:
{
"displayName":"Flight 157",
"mailNickname":"flight157",
"description":"Everything about flight 157",
"visibility":"Private",
"groupTypes":["Unified"],
"mailEnabled":true,
"securityEnabled":false,
"members#odata.bind":[
"https://graph.microsoft.com/v1.0/users/957c07af-dcad-4b72-9306-1c4ee7d04e1f"
],
"owners#odata.bind":[
"https://graph.microsoft.com/v1.0/users/957c07af-dcad-4b72-9306-1c4ee7d04e1f"
]
}
I get the below response error:
{
"error": {
"code": "BadRequest",
"message": "Invalid bind property name members in request.",
"innerError": {
"request-id": "fee10382-5112-44f8-a8c9-683453bdf050",
"date": "2020-03-05T01:08:19"
}
}
}
I am not quite sure what I am doing wrong. Can anyone please help me with this?

Firebase Cloud Messaging sound error

I'm trying to send a notification using firebase api and the notification is sent successfully if I only have "title" and "body" in the notification JSON object. However, if I add "sound":"default" to the notification object, as described in the documentation, I get the following error:
"Invalid JSON payload received. Unknown name \"sound\" at 'message.notification': Cannot find field."
My JSON object is as follows:
{"message":{"token": token, "notification":{"title":"Test", "body":"Test message from server", "sound":"default"}}}
The appearance of message in your JSON indicates you are using the HTTP v1 API. The documentation you linked is for the legacy API.
The HTTP v1 API JSON to send a notification with sound for Android and iOS devices should be:
{
"message": {
"token": "your-token-value",
"notification": {
"title": "Test",
"body": "Test message from server"
},
"android": {
"notification": {
"sound": "default"
}
},
"apns": {
"payload": {
"aps": {
"sound": "default"
}
}
}
}
}

Firebase REST Auth on Android returns 500

Up until last week, the only resonable path available (for a lot of reasons) to use Firebase in a Xamarin.Android app required using Firebase.Xamarin. However, this appears to have stopped working as well.
Specifically, I had been able to successfully make the following call in my Android and iOS apps and get successful responses:
var contentString = $"grant_type=refresh_token&code=string&refresh_token={auth.RefreshToken}";
var requestContent = new StringContent(contentString, Encoding.UTF8, "application/x-www-form-urlencoded");
var uri = new Uri(string.Format("https://securetoken.googleapis.com/v1/token?key={0}", this.authConfig.ApiKey));
var response = await client.PostAsync(uri, requestContent).ConfigureAwait(false);
var responseData = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
As of yesterday, I started getting the following responseData from the above code:
iOS:
{
"error": {
"code": 403,
"message": "Requests from this ios client application \u003cempty\u003e are blocked.",
"status": "PERMISSION_DENIED",
"details": [
{
"#type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developer console API key",
"url": "https://console.developers.google.com/project/<my_apps_project_id>/apiui/credential"
}
]
}
]
}
}
Android:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "ipRefererBlocked",
"message": "The request did not specify any Android package name or signing-certificate fingerprint. Please ensure that the client is sending them or use the API Console to update your key restrictions.",
"extendedHelp": "https://console.developers.google.com/apis/credentials?project=<my_apps_project_id>"
}
],
"code": 403,
"message": "The request did not specify any Android package name or signing- certificate fingerprint. Please ensure that the client is sending them or use the API Console to update your key restrictions."
}
}
After some research, I found this Google Cloud Endpoints Google Groups thread that said to be sure the following are in the http request's headers:
Header x-android-package
Label servicecontrol.googleapis.com/android_cert_fingerprint
Header x-android-cert
Label servicecontrol.googleapis.com/android_package_name
Header x-ios-bundle-identifier
Label servicecontrol.googleapis.com/ios_bundle_id
I added client.DefaultRequestHeaders.Add("X-Ios-Bundle-Identifier", <my_apps_bundle_id>); to my code before the client.PostAsync and it works like a charm.
Moving on to Android, I added "x-android-cert" and x-android-package to the request headers:
client.DefaultRequestHeaders.Add("x-android-cert", <my_apps_SHA1>);
client.DefaultRequestHeaders.Add("x-android-package", <my_apps_package_id>);
prior to my client.PostAsync call. However, now I get the following responseData:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "internalError",
"message": "Internal Error"
}
],
"code": 500,
"message": "Internal Error"
}
}
A moment of venting: For me, this is almost the last straw when it comes to Firebase. It has been over a month of overcoming one undocumented and half-baked API/SDK after another. It seems as if NOTHING works as advertised (including - off topic - getting Firebase working with an Angular4 project). Thank you for letting me share my frustration. Had I known how painful this was going to be, I would have setup my own MBaaS.
Before I give up on Firebase, I wanted to ask for help with this issue. Any insights and assistance would be greatly appreciated.
EDIT 1:*
I get similar results with the following changes:
var requestContent = new StringContent(postContent, Encoding.UTF8, "application/json");
var uri = new Uri(string.Format("https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyAssertion?key={0}", this.authConfig.ApiKey));

Resources