facebook messenger get started button don't send messaging_postbacks - ruby-on-rails

Playing around with a dummy facebook app nd ruby on rails to set-up a messenger bot. My goal is to trigger a sign up when the user first interacts with the bot by clicking the default 'Get Started" button. I have added a get started button this way:
curl -X POST -H "Content-Type: application/json" -d '{
"get_started":{
"payload":"GET_STARTED_PAYLOAD"
}
}' "https://graph.facebook.com/v2.6/me/messenger_profile?access_token=TOKEN
Then received:
{"result":"success"}
By looking at my server logs, I notice I dont get any callback from the user action. I know the webhook is set correctly cause other bot features seems to work right. So here is my question: I use pages_messaging permission on facebook apps, I think the reason why might be I need pages_messaging_subscriptions in order to get back that data. Can this difference explains why I don't get back any data on user clicking Get started?
Any help appreciated

Related

how to send a message to a slack channel?

This must be completely obvious and I am sure I am missing something here but here it goes:
according to slack documentation :
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"This is a line of text.\nAnd this is another one."}' \
https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
but where do I find my account specific parameters to go in here :
T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
According to this page https://www.programmableweb.com/news/how-to-integrate-webhooks-slack-api/how-to/2015/10/20
You get that URL by clicking "Add Incoming Webhook Integration"
When you're done doing whatever it needs, it gives you the URL you need to post to. It's a bit different than using an API token.
As has already been pointed out this is an incoming webhook, which is an easy way to post messages to Slack. The full URL is arbitrary and will be automatically generated for your as soon as you have created the webhook for your Slack team
On the official documentation page about incoming webhooks I am guessing you missed the link in the 2nd paragraph ;-)
"Start by setting up an incoming webhook integration...".
Just click the link to set up your webhook.

Ruby on Rails and Twilio

After following instruction on how to integrate Twilio in ROR apps, I have an issues when making a curl request:
curl -X POST http://localhost:3000/twilio/voice -d 'foo=bar'
Return me:
<html><body>You are being redirected.</body></html>
Thanks!!
Twilio developer evangelist here.
It looks like your /twilio/voice path is lying behind some user authentication. Your controller is being interrupted and sending you to the sign in page instead. You probably don't want user authentication in front of your Twilio routes.
Your app seems to require login before using the service. If you are trying to check using curl , please disable sign_in check. After testing you can enable it again.

Spree commerce: User Login through API

I am pretty newbie using Spree and I am just playing around with the 3.0 stable version.
I would like to log a user account into the store through API (or something like that) using the chrome app called "Advanced REST client", then visit the store and see the account logged there.
I couldn't find any reference for this kind of actions which involve users or accounts through API in https://guides.spreecommerce.com/api/. However, I noticed that if you make a POST request to localhost:3000/login sending the account details, you get the html code of the store which says that your were successfully logged.
After that I checked my browser cookies and the store session cookie was also created successfully. Finally, when I redirect the browser to the store (localhost:3000), the account is not logged in but the cookie still remains there.
I think is something related to the guest token generated by Spree, but I don't understand exactly why it doesn't work.
I would appreciate any help to clear this, also if you have any idea about how to get my goal it also would be appreciated.
In order to use a REST client, such as the Chrome app you mentioned, you have to authenticate against Spree's REST API. You need a spree api token to authenticate future request.
Have a look at the Spree Api Auth Gem. It allows you to you receive an api token like this:
\curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d ' {"user":{"email":"camelmasa#gmail.com", "password":"camelmasa"}}' http://localhost:3000/api/users/sign_in
You can also create new user account using this gem. Since Spree is using devise underneath, you can also use devise directly to authenticate your user.

Facebook Graph API and app secret

I have an iOS application that I'm logging to Facebook to ask for an access_token.
Then I pass this access token to my server and I want to get the '/me' information, using my appsecret_proof but I noticed that I can do it without appsecret_proof:
curl "https://graph.facebook.com/me?access_token=THE_ACCESS_TOKEN"
{"id":"658267751","name":"Ricardo Otero",
"first_name":"Ricardo","last_name":"Otero",
"link":"https:\/\/www.facebook.com\/oterosantos",
"hometown":{"id":"107911285910314","name":"Coimbra, Portugal"},
"location":{"id":"110432202311659","name":"Lisbon, Portugal"}...
Although I have set the option "App Secret Proof for Server API calls" to true:
So, shouldn't the requests require the app secret? I don't get it!
Every access_token depends on app and user so for different app and user combination you will have different access token so you don't need to worry. though I am no sure why are you doing it this way
http://m-farhan.com/2014/03/ios-facebook-sdk-tutorial/
is the right way of doing this.
I am also navigating through the Facebook API "appsecret_proof" parameter -- here are the official docs on Facebook Developers Website:
https://developers.facebook.com/docs/graph-api/securing-requests#appsecret_proof -- it looks like this example PHP call can help you out:
$appsecret_proof= hash_hmac('sha256', $access_token, $app_secret);
Here's the Example Command-Line call they display:
curl \
-F 'access_token=<access_token>' \
-F 'appsecret_proof=<app secret proof>' \
-F 'batch=[{"method":"GET", "relative_url":"me"},{"method":"GET", "relative_url":"me/friends?limit=50"}]' \
https://graph.facebook.com
Here's someone who made a similar call with a Node.JS Server(dosen't look there is speciifc FACebook/API/SDK referecne though... :
Get signed_request in Node.js (Express) Facebook canvas app

Link going to different url

When I share a link form my blog to facebook it goes to a totally different url, it only happens when the link is posted on facebook.
Igy is right consider checking the following in cURL
curl -i http://yourdomain.com -e https://facebook.com
option e sends the "Referer Page" information to the HTTP server.

Resources