Telnyx primary webhook not receiving SMS - php

I have followed all the steps mentoined here : and although I can sent a post request to my webhook url somehow Telnyx is unable to send the message payload here whenever I receive a message.
here is my code
public function receive_incoming_sms(Request $request){
return response()->json('Successfully Received',200);
}
here is the route defined in api.php
Route::post('/receive_incoming_sms', 'App\Http\Controllers\BucketController#receive_incoming_sms')->name('receive_incoming_sms');
but somehow telnyx is dropping the payload on the failover url which i created on https://webhook.site.

Related

Requesting Data for call back url

I am new on working third party API, working on GUPSHUP API and with the help of guzzle I am sending msg to whatsapp but for receiving the message from callback url to my controller what should I use.
Notes-> Callback url which i added on is webhook call back URL , Now when any event happened on that url
how to receive that in my laravel controller, i search all the places where they suggested call webhook client server put a route
Route::webhooks('webhook-receiving-url');
in this i have to put my call back url . but i want to receive this call back url in controller , how to do this , please help me out

How to respond with the correct challenge value when trying to enable event subscriptions for laravel-botman on slack

This is not a duplication of my previous question here.
Am using botman to create a bot for my slack app.
Using the slack api, i have created a bot that i want to connect to botman on my laravel app. Am using ngrok to tunnel localhost. I have to get my url verified first in order to use it for the bot. Well i try to verify the url but i keep getting this error.
Your request URL didn’t respond with the correct challenge value. Update your URL to receive a new request and value.
Checking the ngrok terminal shows that the request from slack is being received and the status is 200. If i reproduce the request using postman, the value of the challenge parameter is returned, on slack i still get the erorr. I use this code to load the slack driver on my routes file.
<?php
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\Drivers\Slack\SlackDriver;
use BotMan\BotMan\Drivers\DriverManager;
Route::match(['get', 'post'],'botman', function () {
DriverManager::loadDriver(SlackDriver::class);
// Create BotMan instance
$config = [
'slack' => [
'token' => '***slack Token***' //slack token
]
];
$botman = BotManFactory::create($config);
// give the bot something to listen for.
$botman->hears('hello', function (BotMan $bot) {
$bot->reply('Hello yourself.');
});
// start listening
$botman->listen();
});
I went a head to try force the response with the challenge parameter in the url like so on my routes file.
$payload = $request->json();
if ($payload->get('type') === 'url_verification') {
return $payload->get('challenge');
}
SlackBot::hears('keyword', function (Bot $bot) {
$bot->respond('lets begin');
});
This still does not work, i still get the URL didn’t respond with the correct challenge value... error.
What am i missing? or how should i use the slack driver to have it respond with the right parameters? The web driver works perfectly.
I noticed that the slack api expects the challenge value in json format.
simply doing return $payload->get('challenge'); . does not do the trick. I changed this to return response->json( return $payload->get('challenge'));. This got my url verified.
Am not sure whether this is an issue with the whole botman slack-driver , I didn't find anyone else with the same issue.

Laravel: How can we know the error when sending HTTP request

I am trying to use a Http method to reactivate user's subscription, using HTTP request, but there might be two problems that exist (the json code would return two potential errors):
Reactivating a canceled subscription with an invalid payment profile
Given you have a canceled subscription with ID "1000"
The subscription has an invalid payment profile
Send a PUT request to https://sample.chargify.com/subscriptions/1000/reactivate.json
The response status should be "422 Unprocessable Entity"
The subscription should be canceled with the following response
{
"errors": ["The credit card on file could not be charged."]
}
Attempting to reactivate an already active subscription
Given you have an active subscription with ID "1000"
Send a PUT request to https://sample.chargify.com/subscriptions/1000/reactivate.json
The response status should be "422 Unprocessable Entity"
The subscription should be active with the following JSON response
{
"errors": ["Cannot reactivate a subscription that is not marked
\"Canceled\", \"Unpaid\", or \"Trial Ended\"."]
}
I am new to Laravel, therefore I would like to know the way I can detect the error when sending the request to the server, but right now I only have one option (without a valid if statement) which cannot detect the problem.
I think an if statement would do but I'm not sure how. Thanks!
Okay so the if statement will work if:
if (isset(response()->error)){
// error message
} else {
// success message
}

Why am I getting error when I use Postman and oauth2 for login access case in apiagility?

I am new to Zend Framework 2. I am trying to get the login access scenario working with Postman (chrome extension). I have gone through the forum but I'm not sure if I'm missing something or not. So here are the steps that I have taken so far:
In MYSQL I have set up the tables accordingly and there is a user with the following fields in the oauth_clients table:
client_id : testclient
client_secret : testpass
redirect_uri : /oauth/receivecode (I'm not sure about the value of
this one could someone please shed some light on this?)
grant_type : password ( I want to use the service for authentication
and authorization to access a website or login access scenario)
The rest of the fields are NULL. No other entries in other tables.
I set the parameters in Postman like this:
Authorization : Oauth2
Headers:
Accept : application/json
Content-Type : application/json
The raw body is like:
{
"client_id":"testclient",
"client_secret":"testpass",
"grant_type":"password"
}
I post the request to:
www.dummy.dev/oauth/authorize
When I post the request this is what I get:
{
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title": "invalid_request",
"status": 302,
"detail": "Invalid or missing response type"
}
Why do I get this error message?
This error is triggered here in the OAuth2 AuthorizeController.
The controller checks whether the $response_type is valid. If not it returns this error message.
On line 313 you see:
protected function getValidResponseTypes()
{
return array(
self::RESPONSE_TYPE_ACCESS_TOKEN,
self::RESPONSE_TYPE_AUTHORIZATION_CODE,
);
}
Those constants are defined in the AuthorizeControllerInterface:
const RESPONSE_TYPE_AUTHORIZATION_CODE = 'code';
const RESPONSE_TYPE_ACCESS_TOKEN = 'token';
So somewhere during the handling of your request this $response_type value is not set correctly. It should either be set as token or code for the request to validate correctly. Not sure where in your config you did something wrong but with this information you should be able to find the problem.
redirect uri is not necessary and could be left null in the database as well. The correct uri to POST is www.dummy.dev/oauth and the raw parameters in Postman are:
{
"client_id":"dev.dummy",
"username":"testclient",
"password":"testpass",
"grant_type":"password"
}
The value of password is stored and encoded (with bcrypt) in the database. client_id and client_secret are not important in this scenario as my own website is the client of my API.

google OAUTH2 exchange authorization code for acces token "invalid request"

I'm getting google api authorization code from this page on my server
https://github.com/google/google-api-php-client/blob/master/examples/user-example.php
the same page on my hosting to test
http://mawk3y.net/google/google-api-php-client/examples/user-example.php
after adjusting client id, secret and redirect uri.
$data =file_get_contents('https://accounts.google.com/o/oauth2/auth?code='.$code.'&client_secret={secret}&redirect_uri={my web page}&grant_type=authorization_code');
print_r($data);
but i get an error so i'm trying to paste the full url to the browser address bar after getting authorization code from that page like this (the same auth code I get from this page https://developers.google.com/oauthplayground/)
https://accounts.google.com/o/oauth2/token?code={authorization code}&redirect_uri=mywebpage.php&client_id={my client id}&client_secret={secret code}&grant_type=authorization_code
but the result is
{
"error" : "invalid_request"
}
how to solve this and exchange the authorization code for access token
You're sending the parameters in a GET request to the authorization endpoint (https://accounts.google.com/o/oauth2/auth), but you must send them in a POST request to the token endpoint (https://accounts.google.com/o/oauth2/token).

Categories