I have logged in a user to my app from FB.login now I want to post to the user timeline on the behalf of user. I want to upload a video to the user timeline. I am doing something like:
FB.api(
`/${user_id}/videos`,
"POST",
{
"file_url": video,
"description": description,
"thumb": video_thumbnail,
"title": title,
},
function (response) {
console.log("fb response")
console.log(response)
if (response && !response.error) {
/* handle the result */
console.log("video upload response")
console.log(response)
}
}, {scope: ['user_videos', 'user_actions.video']});
When I do this it is giving me error saying code: 100
fbtrace_id: "F1BDJWtcTXl"
message: "Unsupported post request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api"
type: "GraphMethodException"
Why I am getting this error ??
Help is appriciated ..
Thank you
Use /me/videos instead of /${user_id}/videos and use single (or double) quotes instead of "`".
Also, you need publish_actions only, and you need to use the scope parameter with FB.login. FB.api is just an API call.
Here´s an example for the login: http://www.devils-heaven.com/facebook-javascript-sdk-login/
And here´s the link to the docs for uploading videos: https://developers.facebook.com/docs/graph-api/reference/user/videos/#Creating
Someone suggested that the App may be in sandbox/dev mode, no sure why this should be a problem but here´s the thread: How to fix "Unsupported post request" when posting to FB fan page?
Related
I´m currently building an Slack app with a modal. I´m using a serverless AWS Stack containing a Lambda function that handles the user interactions. Those interactions are verified in that Lambda.
If the user input is correct, the modal is closed successfully (Lambda returns a 200 response). However, if I return the following as the body when user input is wrong and user submits the modal (as per Slack´s documentation):
{
"response_action" : "errors",
"errors": {
"startDate": "Start date is incorrect.",
},
}
The full response I'm returning at the end of the Lambda function is:
response = {
statusCode: 200,
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
response_action : "errors",
errors: {
"endDate": "Start date is incorrect.",
}
})
};
I receive the error in the next screenshot:
Am I missing something? Thanks a lot.
So I found the problem and here´s the solution in my case (might be helpful to you reader):
The right block type
The modal I built is made of interactive components, like a date picker. These components are blocks of type "section". For better comprehension, they look like this:
However, it seems that´s not compatible with the the feature to display input errors. For that, you have to choose blocks of type "input". Again, for understanding, they look like this:
And that type of block is compatible with displaying error messages as per Slack documentation.
The response from AWS Lambda
When you validate a user input, in the AWS Lambda function, Slack expects you to return the following structure in the response if you want to warn about an error:
{ "response_action": "errors", "errors": { "ticket-due-date": "You may not select a due date in the past" } }
However, it looks like you need to indicate the time of content by adding a header defining content is of JSON type without a statusCode. In my case, response that works is:
response = {
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
response_action : "errors",
errors: {
"test": "That date is invalid. Please, select a future date.",
}
})
And that way, the custom error message appears:
I have the following Facebook Graph API call:
FB.ui({
method: "send",
to: '123123,456456',
name: 'People Argue Just to Win',
link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html'
}, function(response) {
// some stuff
});
Whenever it's invoked, my message's only recipient is the user with id 123123. If I switch the two numbers, the 456456 is the sole recipient.
As far as I can tell, I'm using the API exactly like I'm supposed to, so what could I be doing wrong?
It looks like it's not possible with the send method to specify multiple recipients: http://bugs.developers.facebook.net/show_bug.cgi?id=18806
It does look like it can be done with the apprequests method, though:
FB.ui({
method: 'apprequests',
message: 'My message',
data: {},
title: "My Title",
to: [123123, 456456]
});
For my purposes, that's close enough.
I am not familiar with using Facebook Javascript SDK.
My story is when I access to the website It displays all my friends(pic and name) on a webpage.
I registered Facebook API and App ID
I put website URL as http://localhost:81/ because I am testing my own local machine.
Do you have any good example website or good examples?
Please share with me
Thank you.
First your app should use required permissions like,
user_birthday, friends_birthday, user_location , friends_location...
( for more permissions)
Get info about current user:
FB.api('/me', function(response) {
// Stuff here
});
Get info about current user's friends:
FB.api('/me/friends', function(response) {
// Stuff here
});
you will get the response like,
{data: [{id: "FRIEND1_ID", name: "FRIEND1_NAME"}, {id: "FRIEND2_ID", name: "FRIEND2_NAME"}]....}
If you want get some more properties of your friends, use FIELDS parameter, like
FB.api('/me/friends', {fields: 'name,id,location,birthday'}, function(response) {
// Stuff here
});
If want to get individual user's friend info:
FB.api('/FRIEND1_ID', function(response) {
// Stuff here
});
Try this Example Site
Direct Access Method:
Log into Facebook under your name. If you need an "Access Token", Click on the Extended Permissions and click the "read_friendlist" check box to get your Access Token and then
submit your query. You may need to "Allow" access, so just follow the prompts given.
Voila! You now have the usernames for everyone on your Friends List. The "username" parameter in the query will give you the contact email "message to that person" and you append #facebook.com and send them a message. Very simple.
http://developers.facebook.com/tools/explorer?fql=SELECT%20username%20FROM%20user%20WHERE%20uid%20IN%20%28SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20%3D%20me%28%29%29%20ORDER%20BY%20name
-SAB
I'm trying to post videos from our application to the facebook following their api for the pages: https://developers.facebook.com/docs/reference/api/page/
but facebook returns following response
{
"error": {
"message": "(#353) Missing video file",
"type": "OAuthException",
"code": 353
}
}
this is what i'm putting in the browser:
https://graph-video.facebook.com//videos?access_token=&source=https://www.youtube.com/v/ZVKc8KGPKFM&method=post
but it is still comes back with the same message, does anyone know what is missing? thanks
This is the way Im linking a video to a Facebook page.
$url='https://graph.facebook.com/'.$page_id.'/feed?access_token='.$facebook_page_access_token;
$args = array(
'message' => $message,
'link' => 'http://www.youtube.com/watch?v='.$video_id,
'source' => 'http://www.youtube.com/e/'.$video_id,
'picture' => 'http://img.youtube.com/vi/'.$video_id.'/0.jpg'
);
$this->_curl = curl_init();
curl_setopt($this->_curl,CURLOPT_POST,TRUE);
curl_setopt($this->_curl,CURLOPT_URL,$url);
curl_setopt($this->_curl, CURLOPT_POSTFIELDS, $args);
curl_exec($this->_curl);
Make sure to add "source" in the parameters. otherwise it will display as a normal link in facebook(i.e post_type=link in api response)
I am trying to delete an application tab from a facebook page.
According to the documentation, I should issue a DELETE request to "https://graph.facebook.com/PAGE_ID/tabs/TAB_ID" with a PAGE access token, but when I do so I get the error "(#210) Subject must be a page."
The same happens when trying to update a tab.
I have requested the user for "manage_pages" permission and I have the correct access_token (Adding a tab works perfectly).
the exact request is: https://graph.facebook.com/212757048770606/tabs/app_289329597785433 (with an access token)
Does anyone know what am I doing wrong?? or is there an open bug report?
Thanks alot
I don't have a solution for you, but I do know that I had some problems with removing a tab that boiled down to the fact that the tab's ID (returned from a call to get /PAGE_ID/tabs) already includes the page ID and "tabs" path.
Initially I was building my URL by taking the tab ID and sticking it on the end of /PAGE_ID/tabs/, but that didn't work because the URL ended up being something like /12345/tabs/12345/tabs/app_4567. Once I realized that the tab ID was sort of "compound" already, I got the Remove to work.
Add the page access token to the call of Facebook API
var PageAccessToken = 123456789123456789123456789123456789;
FB.api(
"/{page_id}/tabs",
"POST",
{
"object": {
"app_id": "{page_id}"
}
},{
"access_token": PageAccessToken
},
function (response) {
if (response && !response.error) {
console.log(response);
} else {
console.log(response.error);
}
}
);
function DeleteTabPage(){
var pid = page_id;
var at = access_tocken;
debugger;
FB.api(pid + '/tabs/app_{your app id}', 'DELETE', { app_id: your app id, access_token: at }, function (response) {
debugger;
if (!response || response.error) {
debugger;`enter code here`
alert('Facebook add app error ' + response.error);
} else {
console.log(response);
debugger;
// alert('App has been added');
}
}); /* end of page/tabs*/
}