Comments (7)
I could be wrong, but i think Curl can send only file on the local filesystem, without HTTP.
You could try to download the photo from google App Engine on your server before sending it on Telegram.
from telegrambotphp.
Well, if you use a database or some otherway to store information, you can try this:
When you want to send a picture, check if there is a record on your db like photo | file_id and do a SendPhoto using just the file_id (you should also implement some check to see if the picture is still on the Telegram's servers), If it's not, download the picture on your local webserver, send it using curl, get the file_id from the reply, save the data on the database and delete the picture from your local storage. It's tediuos but the only solution i can see.
from telegrambotphp.
I added public $results
to Telegram class to read the curl_exec($ch)
and I tried this code:
define('BUCKET','gs://<MY_BUCKET_ADDRESS>/folder/');
$contents = file_get_contents("http://www.example.com/255.png");
file_put_contents(BUCKET.'255.png',$contents);
$img = my_curl_file_create(BUCKET.'255.png','image/png');
$content = array('chat_id' => $chat_id, 'photo' => $img );
$telegram->sendPhoto($content);
$telegram->sendMessage(array('chat_id' => $chat_id ,'text' => "Result=".$telegram->results));
file has saved as 255.png in Bucket ,but I received this result :
Result={"ok":false,"error_code":400,"description":"Bad Request: Wrong persistent file_id specified: contains wrong characters or has wrong length"}
from telegrambotphp.
I don't think curl can handle the gs protocol. Try using a file on the local server, or download the png first and then send it using CURL
from telegrambotphp.
Upload a pictute and get file_id, then send file_id with message.
from telegrambotphp.
You're right and I already tried it but when you have to send hundreds of random pictures to bot users how to do it without uploading on my server and sending by multipart to telegram server to get file_Id.
My problem is that my bot is on google app engine server and it does not support direct addressing a file like: /directory/a.jpg and curl doesn't support gs://
from telegrambotphp.
Thanks for comments, after all I found out I had to use custom multipart form data which I got from here
if anyone else has problem with Curl in new php versions or file uploading from google cloud storage
to telegram I would recommend to use it . link from php website
from telegrambotphp.
Related Issues (20)
- Telegram::getChatMembersCount() method
- [BUG]
- Hi~~ @Eleirbag89 pls delete this issue,thanks!
- Web Apps HOT 8
- UpdateCount[BUG] HOT 2
- payment function HOT 1
- you have any video for this bot like tutorial ? HOT 1
- How to make wait for answer HOT 2
- Can you create .phar file for this project HOT 9
- [BUG]
- ErrorException Undefined array key "message" when using funtion UserID() HOT 3
- Formatting options HOT 3
- sendMediaGroup not working! HOT 1
- How to get user_id of the message of a user I reply to? HOT 1
- Add API Support for up to API 6.9 (22.09.2023) HOT 1
- Please Add Forward From Username HOT 1
- My button not a have actions
- how to send sticker HOT 2
- Failed to connect to api.telegram.org port 443 after 21043 ms: Timed out HOT 2
- local-bot-api-server HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegrambotphp.