line / line-bot-sdk-python

LINE Messaging API SDK for Python
https://pypi.python.org/pypi/line-bot-sdk
Apache License 2.0
1.93k stars 1.02k forks source link

What type of Messaging API plan support push message? #20

Closed puyuan closed 7 years ago

puyuan commented 7 years ago

I am trying out Messaging API and couldn't get push_message to work. Is there a specific type of Messaging API that support push_message. It seems I can only reply message.

Here is my error message. {"message":"Access to this API is not available for your account"}

be-hase commented 7 years ago

Hi, @puyuan

It is written this page. https://business.line.me/services/bot

puyuan commented 7 years ago

I see. Seems like when you enable Messaging API for existing channels, you get only reply_message permission. But when creating a new Developer Trial, both permissions are available.
Thanks for clarifying.

be-hase commented 7 years ago

But when creating a new Developer Trial, both permissions are available.

Good. 😄 I hope you will create a good bot. thanks.

Ilaiyaraja221197 commented 2 years ago

I am also having that same problem I can able to send a png,jpg,mp4 files but not able to send jpeg ,document files i tried it gives me

like this response

{"to":"U6ef809bc60c2a8fd9dac9d66940ffbd4","messages":[{"type":"file","originalContentUrl":"https:\/\/ticketing.mconnectapps.com\/apiDoc\/v1.0\/line_image\/Helpdesk api.txt","previewImageUrl":"https:\/\/ticketing.mconnectapps.com\/apiDoc\/v1.0\/line_image\/Helpdesk api.txt"}]}{"message":"The request body has 2 error(s)","details":[{"message":"This message type is not available for your account","property":"messages[0]"},{"message":"May not be empty","property":"messages[0].contentId"}]}

how can i solve this

what can i do here is my code

$url = 'https://api.line.me/v2/bot/message/push';
//$data['originalContentUrl'] = filter_var($data['originalContentUrl'], FILTER_SANITIZE_URL); //$data['previewImageUrl'] = filter_var($data['previewImageUrl'], FILTER_SANITIZE_URL);

    $post = json_encode($data);
    //print_r($post);
    //exit;
    $headers = array('Content-Type: application/json', 'Authorization: Bearer ' . $access_token);
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    $response = curl_exec($ch);//print_r($response);exit;
    curl_close($ch);
    return $response;

//sending data is json {"to":"U6ef809bc60c2a8fd9dac9d66940ffbd4","messages":[{"type":"image","originalContentUrl":"https:\/\/ticketing.mconnectapps.com\/apiDoc\/v1.0\/line_image\/pngwing.com.png","previewImageUrl":"https:\/\/ticketing.mconnectapps.com\/apiDoc\/v1.0\/line_image\/pngwing.com.png"}]}