Wrong response from the webhook: 400 Bad Request - php

I'm recently tried to use webhook to get update from telegram. my program work correctly whit getUpdates().
but when i set webhook i got
"Wrong response from the webhook: 400 Bad Request"
error when try to check status of webhook by getWebhookInfo method.
here is my code:
$telegram->commandsHandler(true)
when is used below code in getUpdates mod every thing was fine.
$telegram->commandsHandler(false)
And is should say i use https and my ssl is ok.
This is answer of getWebhookInfo to me.
{
"ok": true,
"result": {
"url": "https://telbit.ir/api/bot/<token>",
"has_custom_certificate": false,
"pending_update_count": 13,
"last_error_date": 1476344420,
"last_error_message": "Wrong response from the webhook: 400 Bad Request"
}
}

I found my answer
every things was ok. the error happens because of my framework.

Related

Woocommerce webhook response 200 message The Rest API is unavailable

When woocommerce (webhook) send a success message (200) but the body contain the below
{
"errors": {
"rest_api_unavailable": [
"The Rest API is unavailable."
]
},
"error_data": []
}
Has anyone happened this error?
Thanks in advance
I did some additional testing on the site I was experiencing this on and narrowed it down to define('ALTERNATE_WP_CRON', true) being set in wp-config.php. If you have this set, try commenting it out. In my tests, the correct payload was sent every time after commenting this constant out. Also, on a completely different site that I configured the same exact webhook/endpoint on that had no issues, as soon as I set ALTERNATE_WP_CRON to true, it started sending rest_api_unavailable for the payload. Please refer to these links for additional information and bug report:
https://github.com/woocommerce/woocommerce/pull/26878
https://github.com/woocommerce/woocommerce/issues/28363

Client error: bad request. Error 400. NoCaptcha Laravel Anhskohbo

I connect the re-captcha to the site, which is built on Laravel. And when you click on "I am not a robot", and then on "registration", this error appears.
In the past, I connected the re-captcha on the framework yii2. I had no such problems with exceptions. Now I Installed captcha - Anhskohbo NoCaptcha.
The error itself looks like a notification:
Client error: POST https://www.google.com/recaptcha/api/siteverify resulted in a 400 Bad Request response:
{
"success": false,
"error-codes": [
"bad-request"
]
}
According to the Google reCAPTCHA documentation, this error is given when the request is malformed. Can you check what values are being passed to the /siteverify endpoint? The first thing that comes to mind is that the Content-Type: header for the request to Google's endpoint should be application/x-www-form-urlencoded as per this response - this is also true in my experience.

Laravel 5: Guzzle -> getStatusCode on Exception?

I am programming a little application for myself. This application is calling to different websites with the package Guzzle.
However, I want to store every request in my database with the time and the request duration time and the request status code I get. The problem I am facing here right now is that I don't know how to get the http status code when the request fails..
This is my code so far:
$client = $this->getGuzzleClient();
$request = $client->post($url, $headers, $value);
try {
$response = $request->send();
return $response->getBody();
}catch (\GuzzleHttp\Exception\RequestException $e){
dd(array($e, $e->getResponse()));
}
The $e->getResponse() returns null. I also tried to use $e->getStatusCode() or $e->getRequest()->getStatusCode(). Both are not working...
To be absolutely sure the request is valid and I deal with a real exception I call to this website https://httpstat.us/503. This returns a 503 http status code...
So, how can I get the http status code? Do you guys have any idea?
Kind regards and Thank You!
If you catch a ServerException you are catching a 5xx, if the code execution enters there Guzzle has received a 5xx. If you catch a RequestException that includes network errors too. If the code execution enters on the RequestException but does not on the ServerException means that for Guzzle is not a 5xx error but a network error.
$errorstatuscode=$exception->status;
// to get error code from Excetion Object

Error trying to create webhook

I tried to create a webhook for a task in Asana but the only response I'm getting is this:
{
"errors": [
{
"message": "Could not complete activation handshake with target URL. Please ensure that the receiving server is accepting connections and supports SSL",
"help": "For more information on API status codes and how to handle them, read the docs on errors: https://asana.com/developers/documentation/getting-started/errors"
}
]
}
(Status: 400 Bad Request)
I am sending a POST Request via Postman to https://app.asana.com/api/1.0/webhooks with following content:
{
"data":
{
"resource": 123456789012345,
"target": "https://example.com/asana.php"
}
}
The asana.php looks something like this:
$headers = getallheaders();
$secret_token = $headers['X-Hook-Secret'];
header('X-Hook-Secret: ' . $secret_token);
What am I doing wrong? Am I missing something?
According to the Asana API Reference (https://asana.com/developers/api-reference/webhooks),
The target must respond with a 200 OK and a matching X-Hook-Secret header to confirm that this webhook subscription is indeed expected.
When you send the header, do you know what response code is being sent? Perhaps you might want to have a look at the $http_response_code argument in http://php.net/manual/en/function.header.php

PHP/cURL REST 401 / Message Failed

Okay so I get this error:
{"Code":401,
"Errors":[{
"Message":"Web request to 'http:\/\/silverstagingapi.ncrsmblab.com\/oauth2authorizationserver\/OAuth2\/Token' failed."}],
"GUID":"00000000-0000-0000-0000-000000000000",
"IsSuccessful":false,
"Message":"Web request to 'http:\/\/silverstagingapi.ncrsmblab.com\/oauth2authorizationserver\/OAuth2\/Token' failed.",
"Result":null}
IT SHOULD look like this:
{ "Code": 200,
"Errors": [],
"GUID": "00000000-0000-0000-0000-000000000000",
"IsSuccessful": true,
"Message": null,
"Result": {
"AccessToken": "gAAAACDf3PAniQx1BqJ8qKZVlTQEP7JpvOYglvk8dsBV80mWxtmRCHc1CouejnKbsXEgYbOLXjN7rdZo-Bz535wdulxgkxRTmnEBTSgdZo-DkBHrp-HeiwjlBt_uSIhH7IdIr5dU0w4M_6KgUBI5e1_GWClDHvZY8R5GQahkpy24TGAp9AAAAIAAAAA11W-Eg",
"AccessTokenExpirationUtc": "/Date(1445616318650)/",
"AccessTokenIssueDateUtc": "/Date(1445612718666)/",
"Callback": null,
"RefreshToken": null,
"Scope": [ "APIUSER" ] } }
http://pastebin.com/Ryje2B8H
StackOverflow keeps saying the code is unformatted despite Ctrl+K and code tags so I linked to a syntax-highlighted pastebin. The fact I get a JSON Response means the API is functioning / responding. But it doesn't give me anything but a 401 to go off of. I tried fsockopen() before trying curl and it flat out refused the connection. Using cURL I get a response but it fails regardless.
Figured it out. The API was limited to 3 specific software partners so it doesn't matter what keys/secrets/data I have. The API only accepts requests from specific domains or vendors it seems.

Categories