can any body help me to send video not in telegram bot؟
In fact, my problem is that when sending a video note is not sent in a circle.
And it's sent as ordinary as sending a normal video.
I followed all the necessary points are posted the video.
I uploaded the file in :
Mp4 format
Less than a minute
And is square.
And the code I've used:
the main function :
define('API_KEY','Token');
function bot($method,$datas=[]){
$url = "https://api.telegram.org/bot".API_KEY."/".$method;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($datas));
$res = curl_exec($ch);
if(curl_error($ch)){
var_dump(curl_error($ch));
}else{
return json_decode($res);
}
};
send video note :
bot("sendVideoNote",[
"chat_id"=>$chat_id,
"video_note"=>$video_file_id,
]);
And with the place of this variable video_file_id ["file_id"], I used the direct address of the files, but I did not get any results in bot.
thanks for your helping...
As stated in the Telegram Bot Api:
Sending video notes by a URL is currently unsupported.
This leads to video notes that are passed by an URL to be displayed as normal videos.
However, you can upload the file directly to create a real video note. Using CURLFile it would work as following:
$path = "path/to/video.mp4";
$realpath = realpath($path);
bot("sendVideoNote",[
"chat_id" => $chat_id,
"video_note"=> new CURLFile($realpath))
]);
Related
I am using google app script to Call UPS api and generate shipping label. However the API response is truncated and i am unable to decode base64 encoded image which is part of the JSON response object as it is truncated.
I am also not getting any truncation error messages or responses from the UPS servers, neither is google apps script throwing an error
Have contacted UPS support with the JSON request and it seems to works fine at their end.
// Here is the code for API call.
function getLabel() {
var userName = "myUPS_username";
var password = "*********";
var accessKey = "my_access_key";
var transId = "Trans123";
var transactionSrc = "upstest";
var url = "https://wwwcie.ups.com/ship/v1807/shipments";
var header = {
'AccessLicenseNumber' : accessKey,
'password' : password,
'transId' : transId,
'transactionsrc' : transactionSrc,
'username' : userName
};
// parameters for url fetch
var params = {
'method': 'GET',
'contentType': 'application/json',
'headers': header,
'payload' : JSON.stringify(payload)
};
// call the UPS Shipment API
var response = UrlFetchApp.fetch(url, params);
}
Not including the JSON payload here
Answer:
UrlFetchApp() has functionality and response limitations, including POST and response sizes.
More Information:
As per the Apps Script Documentation, URL Fetch has Limitations which are implemented in the methods themselves. The limitations are as follows:
URL Fetch response size: 50MB/call
URL Fetch headers: 100/call
URL Fetch header size: 8kB/call
URL Fetch POST size: 50MB/call
URL Fetch URL length: 2kB/call
Unfortunately, there is no way to get around this.
Feature Request:
There is a Feature Request on Google's Issue Tracker requesting the increase of the UrlFetch response size limit already. This Feature Request can be found here, which you can give a star (☆) in the top left to let Google know more people wish for this request. There is already a response from them saying 'We'll consider raising the quota if there is enough interest from the developer community.', so letting them know this is a wanted feature is a good way to go.
References:
Google's Issue Tracker
Increase the UrlFetch Total Bytes quota Feature Request
Quotas for Google Services
Current Quotas
Current Limitations
I am following this documentation to convert text to speech using the Text To Speech REST API.
I'm successfully able to get a valid response using Postman and I'm able to pay the audio in PostMan. But I am not able to play the audio using JavaScript. Below is my Javascript code. I'm not sure what to do with the response.
function bingSpeech(message) {
var authToken = "TokenToCommunicateWithRestAPI";
var http = new XMLHttpRequest();
var params = `<speak version='1.0' xml:lang='en-US'><voice xml:lang='en-US' xml:gender='Female' name='Microsoft Server Speech Text to Speech Voice (en-US, JessaRUS)'>${message}</voice></speak>`;
http.open('POST', 'https://speech.platform.bing.com/synthesize', true);
//Send the proper header information along with the request
http.setRequestHeader("Content-Type", "application/ssml+xml");
http.setRequestHeader("Authorization", "bearer " + authToken);
http.setRequestHeader("X-Microsoft-OutputFormat", "audio-16khz-32kbitrate-mono-mp3");
http.onreadystatechange = function () {
if (http.readyState == 4 && http.status == 200) {
// I am getting the respone, but I'm not sure how to play the audio file. Need help here
}
}
http.send(params);
}
Thanks.
I referred to the following repository for my code in Java. It plays the audio in IDE and saves the audio file to your system.
https://github.com/Azure-Samples/Cognitive-Speech-TTS/tree/master/Samples-Http/Java/TTSSample/src/com/microsoft/cognitiveservices/ttssample
I am new to php and GCM. i am using following code to send gcm message using php and mysqldb as i am getting notification successfully however the android guidelines state that gcm message should be send in batch of 1000 each so i am looking for a solution so i can send notification in chunks so all user will receive the notification. i have seen some answers on some similar question but no one seems to be as much detailed for a beginner.
My question is that how i will be able to send GCM message more then 1000 user in one time as i have more then 20,000 users in my scenario. how i will be able to make 1000
Below Is The Code
<?php
include_once 'db_functions.php';
$db = new DB_Functions();
$appId= $_POST["appIdSelect"];
if($appId==0)
{
echo "App not selected, Please choose app first!!";
return;
}
$users = $db->getAllDevicesByAppId($appId);
$message = $_POST["message"];
$message = array("alert" => $message);
$i=0;
while ($row = mysql_fetch_array($users)) {
$regId = $row["device_id"];
//$regId."<br/>";
include_once './GCM.php';
$gcm = new GCM();
$registatoin_ids = array($regId);
$result = $gcm->send_notification($registatoin_ids, $message);
$result;
$i++;
}
echo "Notification send to APP ID= ".$appId." successfully. Total notification sends = ".$i;
?>
The 1000 limit is for when using the registration_ids parameter.
For your scenario, it is suggested to make use of Topic Messaging. Depending on which platform your users are, you simply have to have them subscribe to your topic, and as soon as you send a message to that topic, all subscribers will receive that message.
With all that said, is there a reason why you're not using the newer version of GCM which Firebase Cloud Messaging (FCM)?
I want to have only audio stream communication between peers , I changed the parts of kurento.utils.js to get only audio stream via getusermedia
but it's not working
I used this example node-hello-world example
WebRtcPeer.prototype.userMediaConstraints = {
audio : true,
video : {
mandatory : {
maxWidth : 640,
maxFrameRate : 15,
minFrameRate : 15
}
}
};
to
WebRtcPeer.prototype.userMediaConstraints = {
audio : true,
video : false
};
is it possible use kurento service for only audio stream?
This is indeed possible with Kurento. There are two ways of doing this, depending on the desired scope of the modification:
Per webrtc endpoint: when you process the SDP offer sent by the client, you get an SDP answer from KMS that you have to send back. After invoking the processOffer method call, you can tamper the SDP to remove all video parts. That way, your client will send back only audio.
Globally: You can edit /etc/kurento/sdp_pattern.txt file removing all video related parts, this will force SdpEndpoints (parent class of WebrtcEndpoint) to only use audio.
EDIT 1
The file sdp_pattern.txt is deprecated in KMS 6.1.0, so method 2 shouldn't be used.
EDIT 2
There was an issue with the kurento-utils library, and the client was not correctly setting the OfferToReceiveAudio. It was fixed some time ago, and you shouldn't need tampering the SDPs now.
git origin: https://github.com/Kurento/kurento-tutorial-js.git
git branch: 6.6.0
My solution is only changing var offerVideo = true; to var offerVideo = false; in generateOffer function of kurento-utils.js file.
My approach is to modify the options that you pass to the WebRtcPeer.
var options = {
onicecandidate: onIceCandidate,
iceServers: iceServers,
mediaConstraints: {
audio:true,
video:false
}
}
Besides, in the kurento-utils.js, the mediaContraints is overidden by this line:
constraints.unshift(MEDIA_CONSTRAINTS);
So comment it.
Front end is 100% JS. User click on sign in button and an authResult['code'] is received and send via ajax to localhost/api/user/login which has the following content:
$code = $data['code'];
require_once 'Google/Client.php';
$client = new Google_Client();
$client->setClientId('xxxxxx');
$client->setClientSecret('xxxxx');
$client->setRedirectUri('http://localhost:8080');
$client->setScopes('email'); //Why do I need this? I already set scope in JS.
$client->authenticate($code); //It fails here. with no error. just 400 bad request.
$token = json_decode($client->getAccessToken());
$reqUrl = 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=' .
$token->access_token;
$req = new Google_HttpRequest($reqUrl);
$tokenInfo = json_decode(
$client::getIo()->authenticatedRequest($req)->getResponseBody());
//Check errors.
//Save user personal info in database
//Set login sessions
Why do I need to set scopes if I already set them in javascript?
Why is it failing when authenticate function is called? Im getting no erros.
Why do I need a setRedirectUri() when it is on the backend?
You don't need to set scopes in this case.
(see answer 3, but also): Check your client ID matches the one used in the Javascript, and that the client secret is exactly as in the console (no trailing/leading spaces).
Changing your redirecturi to 'postmessage' - this is the string used when the code was generated via the Javascript process.
You can also try manually constructing the URL and calling it with curl to make sure everything is as you expect: https://developers.google.com/accounts/docs/OAuth2WebServer#handlingtheresponse