I'm sorry if the question is a newbie question but I can't seem to find the answer.
I'm following the Open Graph Tutorial. I am in Step 4: Publish Actions. I am at the chapter Publish an Action. The tutorial says:
"The Open Graph Dashboard page has a 'Get Code' link next to your action. This contains curl code snippets that you can copy into terminal and run directly."
Here is my curl code snippet:
curl -F 'access_token=(myaccess_token_replaced)' \
-F 'podcast=http://samples.ogp.me/(code replaced)' \
'https://graph.facebook.com/me/myapname:listen'
What do I do with this code snippet? I entered the code snippet in my PuTTY terminal and all I got back was a response:
{"id":"341348384144"} (not the actual id number)
I thought it would return more code than that. The tutorial has a new block of code in the example.
<script type="text/javascript">
function postCook()
{
FB.api('/me/YOUR_NAMESPACE:cook' +
'?recipe=http://example.com/cookie.html','post',
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post was successful! Action ID: ' + response.id);
}
});
}
</script>
Do I hand code this and just replace the response.id with the id code that I got back from the curl code snippet?
Please / Thanks.
I believe that ID is the identifier for the action you just posted. It should be unique each time you HTTP post to that url. I believe the CURL code was to be for you to play with just like the Graph API explorer tool is used to play with the graph API. The javascript code you posted above is another example of how to accomplish the same thing that the CURL code did (at least it appear that way to me)
Related
I am using a sample from https://learning.postman.com/docs/running-collections/building-workflows/.
My request is named "MyTestRequest." It is a POST request. In the "Tests" tab of the request, I have the following code:
var i = 0;
while (i < 3) {
postman.setNextRequest("MyTestRequest");
console.log("Iteration:" + i);
i++;
}
When I click on the Send button, I should be seeing four POST requests. The first POST happens even before the above code gets executed.
However, I see only one POST request. Although I do see three console log lines, it appears setNextRequest is not doing anything.
My code is no different than the example in the document. Wondering if anyone has any insight. Thanks.
I'm following a video which explain how to create a skill and intents, to use Alexa. (Here is the link to see this video: https://www.youtube.com/watch?v=YMb0y66UCxs)
I have a problem, I can't go inside an Intent but I can run the skill with the sentence "Alexa open [Name of the skill]". I will show you the index.js from aws and after that the JSON file from developer amazon.
AWS
And here, the JSON:
I built this project in english in the developer amazon website, but i live in france. Maybe I can have a conflict there. And i also choose, in aws, the city east USA (virginia...). So when i say : ask [name of the skill] for [Un unterance], i have this problem:
When I click on the exclamation point, it says: "There was an issue processing your input". Do you see my problem ?
I don't know, and I could be wrong, but do you need to add a GetNewFactHandler? It doesn't look like you defined one anywhere and your trying to add it in .addRequestHandlers.
Based on the other handlers in your code I'm guessing it should look something like this:
const GetNewFactHandler = {
canHandle() {
const request = handlerInput.requestEnvelope.request;
return request.type === 'IntentRequest' && request.intent.name === 'GetNewFact'
},
handle(handlerInput) {
return handlerInput.responseBuilder
.speak('Hello from the get new fact intent')
.getResponse()
}
}
Oh sorry, I just forgot to put the part where I have this code in my aws.
The forgotten part
the bash command I used to connect the bot is: curl -ik -X POST 'https://graph.facebook.com/v2.6/me/messages?access_token=#AccessToken'
My error message is:
{"error":{"message":"(#100) The parameter recipient is
required","type":"OAuthException","code":100,"fbtrace_id":"EFqWAGq2ABs"}}
Do anyone how to solve it ?
Just in case anyone missed this, I encountered this issue when I accidentally use the wrong content type - I was using application/x-www-form-urlencoded instead of application/json
So my advise overall is,
Check if you are indeed passing the parameter
Double check the characters and encoding
Make sure to use the correct endpoint
and Make sure to use the correct content type when posting the JSON Request.
You need to send the recipient id param. Try:
curl -X POST -H "Content-Type: application/json" -d '{ "recipient":{"id":"YOUR RECIPIENT ID" }, "message":{ "text":"hello from bot" }}' "https://graph.facebook.com/v2.6/me/messages?access_token=YOUR_ACCESSTOKEN"
Best regards.
There is another reason for this error message: when you send incorrect characters (like a -tab-) Facebook return this error as well so check your return text on special chars.
Please use the "thread_settings" endpoint "https://graph.facebook.com/v2.6/me/thread_settings" as your API endpoint.
You are using the messages endpoint.
It comes down to the logic of your bot. I got this error as well just recently and it took me days to debug it. The problem for me was I called the callSendAPI(messageData) method outside of the function that compiled the messageData object.
Obviously, passing messageData outside of the function that compiles it sends an empty object instead of the compiled one. Thus the error message (#100) The parameter recipient is required. Simply because the empty object doesn't have any receipientId defined.
Please check your code's logic to ensure you didn't do the same mistake as I. Hope this helps :) Happy programming.
The endpoint is wrong. Instead of https://graph.facebook.com/v2.6/me/messages?access_token=#AccessToken, use this endpoint
https://graph.facebook.com/v2.6/me/messenger_profile?access_token=<PAGE_ACCESS_TOKEN>
This happens when we do not read the documentation., the info is right here https://developers.facebook.com/docs/messenger-platform/discovery/welcome-screen#,
right under the "Setting the Get Started Button Postback".
I got similar error some time back. Try using Postman. I tried the same request and replaced the user id and the page access token. It works fine.
Click on the Import button on the top and paste your curl request under raw. Then try running the call. If you get the same error, go to the body and modify it. Make sure you put this in the body part of the Postman request. Replace the recipient id with yours.
{
"recipient":
{
"id":"123456789"
},
"message":
{
"text":"hello, world!"
}
}
This is the full cURL call : Change Recipient ID and Page Access Token
curl -X POST -H "Content-Type: application/json" -d '{ "recipient":{"id":"1234567" }, "message":{ "text":"hello from bot" }}' "https://graph.facebook.com/v2.6/me/messages?access_token=PASTETHETOKENHERE"
This issue may also occur when you have an error in your code (syntax or logic error). In my case, I had this part in my code in webhook.php (which is my registered callback page in Facebook)
$message = $input['entry'][0]['messaging'][0]['message']['text'];
"message":{
"text":"Sorry, we currently do not have an article related to "'.$message.'"."
}
By the time I registered https://domain.com/webhook.php as callback, it wouldn't receive any $message yet so it causes an error and wouldn't accept my callback url.
Check your code and make sure you echo only the challenge.
$challenge = $_REQUEST['hub_challenge'];
$verify_token = $_REQUEST['hub_verify_token'];
if ($verify_token === 'verify_token') {
echo $challenge;
}
I'm trying to integrate Facebook sharing into a webpage using this code edited from their official developer tutorial, but I'm not having any luck.
function postToFacebook(item_id)
{
FB.api(
'/me/completeset:display',
'post',
{ item: 'http://completeset.us/item/'+item_id },
function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Share was successful! Action ID: ' + response.id);
}
}); //End api
}
I've got the app set up, with an "item" object and the "defined" action defined. I haven't been able to submit the action yet though, because I haven't been able to post anything with it yet. I've verified that the item_id is being passed in correctly, and I've debugged the url using their debugging tool. When I call this function I'm getting unknown path components/ completeset:display. I haven't been able to find much information on this error, so I'm wondering: what are the causes, and how might I be able to fix it?
The names mismatched. The getCode link for the action on facebook displayed the name of the action as being show_off for some reason. It was the same problem as the linked question. I experimented with the app backend and found that if you create an action with one name and then change the name of it, it will display with the new name but you must still reference it using the old name in the code.
Using the current PHPSDK and API (ie not FBJS or the REST approach) I am trying to work out how to paste to a fanpage wall and struggling to find any hints...
I have successfully (through various attempts)
posted to my wall
posted to a friend's wall
posted to the page's wall (when I like the page before posting)
posted to the page's wall (as the page)
So I am looking to work out what I need to do to access_code/permissions or code to have something like :
$result = $facebook->api(
'/<PAGEID>/feed/',
'post',
array('access_token' => <ACCESSCODE>, 'message' => 'Test message')
);
or
FB.api('/<PAGEID>/feed', 'post', {access_token:<ACCESSCODE>, message:'Test message'},
function(response) {
if (!response || response.error) {
alert(response.error.message);
} else {
}
});
working where a post will appear on the feed of page's wall... However I am currently unable to find a way to post to a page wall for a page that I have not explicitly said I like by using the Graph API in PHP...
I am sure it is possible judging by some of the page walls I have seen.
Searching on google and forums tends to lead to old API implementations (which no longer function) or using methods no longer supported. It seemed that the Templatized function could have been what I was looking for (but again that has been deprecated).
What am I doing wrong?
You have to have one of the page administrators give your app "publish_stream" permission. Something like this:
$session = $facebook->getSession();
$perms = 'publish_stream';
echo '<fb:login-button perms="' . $perms . '"></fb:login-button>';
Once the click the button and approve you, your callback url will get called with their session information.
Once you have that you can post to the wall of any page they administer. Using code like what you show in your question.