I'm trying to integrate webhook into my project, I have verified the webhook successfully, but when I send sample data to the server, my server does not receive anything, my project developed on Codeigniter.
I tried using postman to post Json data to the webhook url that was authenticated, my server received
Postman: [POST] https://xxxxxx.xxx/api/webhook
[RAW]
{
"field": "conversations",
"value": {
"page_id": 4444444,
"thread_id": "t_mid.14833205540:9182a4e489"
}
}
Code:
public function webhook(){
if (isset($_GET['hub_mode']) && isset($_GET['hub_challenge']) && isset($_GET['hub_verify_token'])) {
if ($_GET['hub_verify_token'] == 'EcyUykjnmredclnuYFLShBKHfutRFfDRdfdfb'){
echo $_GET['hub_challenge'];
}
}
$data = file_get_contents("php://input",true);
$myfile = fopen("./my-assets/uploads/text.txt", "w");
fwrite($myfile, $data);
fclose($myfile);
http_response_code(200);
}
Related
I've bluid a bot in Twilio AutoPilot and once my bot collected all the information, I need it run a redirect to a webhook.
This webhook works outgoing (I do receive the collected information on the end point) however I'm getting an 90100 error.
This is my code for the webhook:
Code of webhook in Twilio Functions
exports.handler = function(context, event, callback) {
const response = {
actions: [
{
"say": "ik heb denk ik een call naar Zapier gemaakt."
},
{
"redirect": {
"uri": "https://hooks.zapier.com/hooks/catch/xxxxxxxx/oxp6a20/?client=" + event.UserIdentifier + "&materiaal=" + event.Field_materiaal_Value.toLowerCase(),
"method": "POST"
}
}
]
}
callback(null, response);
};
What am I doing wrong?!
I have implemented reCaptcha in TYPO3 website and after integrated Google reCaptcha V2 api even I am getting spam emails. In reCaptcha admin panel I did not see any erros and warnings messages. I also implemented server side validation and Verifying the user's response.
But I did not understand why I am getting spam emails after integrated reCAPTCHA?
Server side Validation
if(isset($_POST['captcha']) && !empty( $_POST['captcha']) && ($_SERVER['REQUEST_METHOD'] == 'POST')){
$captcha=$_POST['captcha'];
}
if (empty($_POST['captcha'])) {
exit('Please set recaptcha variable');
}
$secret="************************************";
$response = $captcha;
$verify = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . urlencode($secret) . '&response=' . urlencode($response));
$captcha_success=json_decode($verify);
if ($captcha_success->success==false) {
echo '<h2>You are spammer ! This user was not verified by recaptcha.</h2>';
}
else if ($captcha_success->success==true) {
echo '<h2>Thanks for posting </h2>';
}
{
"success": true,
"challenge_ts": timestamp,
"hostname": string,
}
I am trying to validate response body including errors in postman. How can I validate the response and text below?
{
"responseHeader": {
"publisherId": "12345",
"responseId": "abbcb15d79d54f5dbc473e502e2242c4abbcb15d79d54f5dbc473e502e224264",
"errors": [
{
"errorCode": "1004",
"errorMessage": "XXXX Not Found"
}
]
}
}
These are my tests which are failing:
tests['response json contains responseHeader'] = _.has(responseJSON, 'responseHeader');
tests['response json contains errors'] = _.has(responseJSON, 'responseHeader.publisherId');
tests["Response has publisher id"] = responseJSON.publisherId === 10003;
In the "Test" tab, parse your response body into an object, then use JavaScript to perform your tests.
var data = JSON.parse(responseBody);
tests["publisherId is 12345"] = data.responseHeader.publisherId === "12345";
Take a look at the test examples at the Postman site:
https://www.getpostman.com/docs/postman/scripts/test_scripts
https://www.getpostman.com/docs/postman/scripts/test_examples
It would be extremely useful to replace our existing interface with Smartsheets, since the client already uses Smartsheets and our prototype is a bit clunky. To that end, I'm building a prototype in order to the learn the Smartsheet API, and it breaks when I try to set up a webhook.
Here's the output when I attempt to update/enable a webhook:
{"message": "SUCCESS",
"resultCode": 0,
"result": {
"id": 4253946970695556,
"name": "Webhook_test",
"apiClientId": "3oqnphhimgqzyimk40",
"apiClientName": "ChoiceIP",
"scope": "sheet",
"scopeObjectId": 7055538769946500,
"events": [
"*.*"
],
"callbackUrl": "https://ghwd.net/write_requests_to_log.php",
"sharedSecret": "kpnc4nz7gwy91yjzcah2s6neq",
"enabled": false,
"status": "DISABLED_VERIFICATION_FAILED",
"disabledDetails": "An error occurred during SSL handshake. (ref id: fwhc0949r7km)",
"version": 1,
"createdAt": "2016-07-06T12:04:13Z",
"modifiedAt": "2016-07-07T06:04:20Z"
}
}
Here's the code from the script that is supposed to create a response:
$headers = getallheaders();
if( isset( $headers['smartsheet-hook-challenge'] ) ) {
header("Smartsheet-Hook-Response: " . $headers['smartsheet-hook-challenge']);
echo $headers['smartsheet-hook-challenge'];
return;
} else if( isset( $_POST['smartsheet-hook-challenge'] ) ) {
header("Smartsheet-Hook-Response: " . $_POST['smartsheet-hook-challenge']);
echo $_POST['smartsheet-hook-challenge'];
return;
} else {
header("Smartsheet-Hook-Response: debug");
}
Why is the SSL handshake failing?
You will need to have a valid SSL certificate setup for the domain ghwd.net or use a domain that has a valid SSL certificate.
When you create a webhook, Smartsheet will first try to connect to your callback URL over a secure connection. If a secure connection cannot be made the webhook will be disabled with the status you are seeing, DISABLED_VERIFICATION_FAILED.
Smartsheet Webhook Documentation
I'm trying to get the realtime updates to my app from facebook using their realtime api. I have configured my subscription.
{
"data": [
{
"object": "user",
"callback_url": "https://myappname.herokuapp.com/realtime.php",
"fields": [
"activities",
"feed",
"is_app_user",
"likes",
"online_presence",
"photos",
"picture",
"status",
"wall_count"
],
"active": true
}
]
}
I have created an endpoint which simply logs the request when I get a post request. But I don't seem to be getting any calls from facebook. If I manually do a post to the end point, it logs the post body json. I have checked the heroku logs but there is no trace of post request form fb, only my manual request is present.
<?php
$method = $_SERVER['REQUEST_METHOD'];
if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe') {
echo $_GET['hub_challenge'];
} else if ($method == 'POST') {
$data = file_get_contents("php://input");
$json = json_decode($data, true);
error_log("update recieved");
error_log('updates = ' . print_r(json, true));
pg_close($db);
}
?>
I have did a callback request test specified by
https://graph.facebook.com/yourappid/subscriptions?access_token=youraccesstoken&object=user&fields=feed&verify_token=yourownsecretstringsetinyourphpfile&method=post&callback_url=http://www.yourwebsite.com/facebook_subscribe.php
which returned me null indicating subscription is success.
I have made a few status updates and likes but I'm not getting any updates from fb. Am I missing something out here?
Thanks in advance.
It's a bug but FB has labelled it as invalid.
Upvote this: https://developers.facebook.com/bugs/394779173962716