facebook api v 1.0 asking for approve permission user_likes - facebook

Facebook Logon Dialog show warning message
The following permissions have not been approved for use and are not being shown to people using your app: user_likes.
Submit them for review or learn more.
But according to documentation it shouldn't, because my app created before April 30th, 2014.
Link to app: https://www.facebook.com/brights.com.ua/app_327215967365892
Js code:
window.fbAsyncInit = function () {
FB.init({
appId: FB_APP_ID,
status: true,
cookie: true,
xfbml: true
});
};
(function (d) {
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) { return; }
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/ru_RU/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
function facebookLogon(callback, callbackCancel) {
FB.login(function (response) {
if (response.authResponse) {
callback(response.authResponse.accessToken);
} else {
if (callbackCancel) {
callbackCancel();
}
}
}, { scope: FB_PERMISSIONS, privacy: "{ 'value': 'EVERYONE' }" });
};

Related

login with facebook returning not a valid app id

i'm using flask, and this is the code on the back end, copied from a source listed on flask-dance documentation:
app.config["FACEBOOK_OAUTH_CLIENT_ID"] = os.environ.get("xxxxxxx")
app.config["FACEBOOK_OAUTH_CLIENT_SECRET"] = os.environ.get("yyyyyy")
facebook_bp = make_facebook_blueprint()
app.register_blueprint(facebook_bp, url_prefix="/login")
#app.route("/")
def index():
if not facebook.authorized:
return redirect(url_for("facebook.login"))
resp = facebook.get("/me")
assert resp.ok, resp.text
return "You are {name} on Facebook".format(name=resp.json()["name"])
on the front end, i have this, provided by facebook itself:
window.fbAsyncInit =
function()
{
FB.init
(
{
//Generate through Facebook developer page
appId:"xxxxxxx",
cookie: true,
xfbml: true,
version: "v4.0"
}
);
getLoginStatus();
}
function getLoginStatus()
{
FB.getLoginStatus(function(res){
if( res.status == "connected" ){
FB.api('/me', {fields: 'first_name,last_name,name,id,picture.width(150).height(150)'}, function(fbUser) {
// console.log(fbUser.name);
var id = fbUser.id;
var name = fbUser.name;
date = new Date().toLocaleString();
var my_data = {name:name,id:id,date:date,language:language};
$.ajax({url: "/fb",data: my_data,type: 'POST',
success: function(response) {
console.log(response);
},
error: function(error) {
console.log(error)
console.log('error in fb');
}})
});
}
});
}
function checkLoginState()
{
getLoginStatus();
}
(
function (d, s, id)
{
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)){return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}
)(document, "script", "facebook-jssdk");
i'm 100% sure both the app id and app secret are correct (just copied and pasted it). i checked another stackoverflow topic on this issue and people were suggesting the OP to make sure he wasn't on sandbox mode. i never even heard of it, but i did try switching to debug=False.

Facebook SDK 2.8 doesnot give email address

I am trying to implement FacbookSDK 2.8 for my website and below is the simplified version of the code.
<button onclick="logout()">Logout</button>
<button onclick="login()">LogIn</button>
<script>
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
setTimeout(() => {
window.fbAsyncInit = () => {
FB.init({
appId: 'xxxxxxx', //My app id here
cookie: true, // enable cookies to allow the server to access
// the session
xfbml: true, // parse social plugins on this page
version: 'v2.8' // use graph api version 2.8
});
checkFBLoginStatus();
}
})
function checkFBLoginStatus() {
FB.getLoginStatus((response) => {
console.log(response)
});
}
function logout() {
FB.logout(function(response) {
console.log(response)
})
}
function login() {
FB.login(function(response) {
console.log(response)
FB.api('/me?fields=id,email,name', function(response) {
console.log(JSON.stringify(response));
});
}, {
scope: 'email'
})
}
function onLoginSuccess() {
FB.getLoginStatus(function(response) {
console.log(response)
})
}
</script>
I am getting the response on logout and login
Here are my questions
On FB.api call i am getting only ID and Name whereas i need user email to set as an unique user identifier.
When is the condition i can achieve not_authorized. I am getting status 'connected' if i login and 'unknown' if i logout. I am not able to reproduce the condition un_authorized, so that i could code for it.
You should use the ID of the user to identify him, not the email. Users do not have to have an email, they can also use their phone number to login. Make sure you get asked for the email permission in the login process/popup. Also, use this form instead:
FB.api('/me', {fields: 'id,email,name'}, function(response) {
console.log(JSON.stringify(response));
});

Facebook app is just posting content on my wall?

I have created a Facebook app which will share a link to users wall
but the issue is the link is posted on my wall but not on any other user's wall
i have put on live link Link to post on wall app
the code of app that will post on users wall is given below is there anything i need to approve it from the facebook or is there any mistake in my code please i need a real help any one could do ?
waiting for your kind response i am new to the Facebook API
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
// init the FB JS SDK
FB.init({
appId: '763390233734216', // App ID from the app dashboard
//channelUrl : '//local.facebook-test/channel.html', // Channel file for x-domain comms
status: true, // Check Facebook Login status
xfbml: true, // Look for social plugins on the page
oauth: true // Enable oauth authentication
});
// Additional initialization code such as adding Event Listeners goes here
FB.login(function(response) {
if (response.authResponse) {
console.log(response.authResponse.accessToken);
var params = {};
params['name'] = 'Seasons Canola';
params['description'] = 'Description';
params['link'] = 'http://vimeo.com/99708842';
FB.api('/me/feed', 'post', params, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
} else {
alert('Not logged in');
}
}, {
scope: 'public_profile,email,publish_actions'
});
};
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

Post feed with js sdk to pagewall

Im trying to send posts to a wall of a page im an admin to through the js sdk. I have made it do i can do it for myself(my personal user) but i cannot get it to work as the "page".
<div id="fb-root"></div>
<script type="text/javascript">
function SendToFacebook()
{
window.fbAsyncInit = function () {
// init the FB JS SDK
FB.init({
appId: '**CORRECT ID**', // App ID from the app dashboard
channelUrl: '**MYPAGE**/channel.html', // Channel file for x-domain comms
status: false, // Check Facebook Login status
xfbml: true // Look for social plugins on the page
});
FB.ui(
{
method: 'feed',
name: 'MyFeed',
link: '',
// picture: '',
caption: 'My caption',
description: 'test',
message: 'MESSAGE?',
},
function (response) {
if (response && response.post_id) {
alert('Delat på facebook.');
} else {
alert('Inte delat på facebook.');
}
}
);
// Additional initialization code such as adding Event Listeners goes here
};
// Load the SDK asynchronously
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
}
</script>
This posts to my own user page, and ive tried the "to" parameter but it send the post from my personal user to the page. Is there any way to make this though the login function?
bare in mind that im fairly new to this so demos and examples are welcome.
I got it to work after a hard days work, if any1 is interested heres how i did.
<script type="text/javascript">
function SendToFacebook()
{
window.fbAsyncInit = function () {
// init the FB JS SDK
FB.init({
appId: '***', // App ID from the app dashboard
channelUrl: '***', // Channel file for x-domain comms
status: false, // Check Facebook Login status
xfbml: true // Look for social plugins on the page
});
FB.login(function (response) {
FB.api('/me/accounts', function (apiresponse) {
var data = {
message: "mymessage",
display: 'iframe',
caption: "caption",
name: "name",
description: "description",
to: **wallid**,
from: **wallid**
};
FB.api('/**wallid**/feed', 'post', data, function () {
console.log(arguments);
});
});
}, { scope: 'manage_pages' });
};
// Load the SDK asynchronously
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
} (document, 'script', 'facebook-jssdk'));
}
</script>
I found this solution and I tried it, although I dont know how it was 3 years ago, now you need to append page access token you receive via /me/accounts calling (also you must be admin of that page etc.) so todays working solution could look like this:
FB.api('/me/accounts', function (apiresponse) {
console.log(apiresponse);
var data = {
message: "mymessage",
//display: 'iframe',
caption: "caption",
picture: 'www.bla.com/image.jpg',
link: 'www.facebook.com',
name: "name",
description: "description",
to: **APP IP**,
from: **APP IP**,
access_token: apiresponse.data[0].access_token
};
FB.api('/**APP IP**/feed', 'post', data, function () {
console.log(arguments);
});
});

Facebook APi Post to page always not allowing to post always unauthorized?

I am having problem integrating the facebook post to wall for pages (not user).
I have already authorized the app for all the scoop.
Scoop lists:
user_about_me,user_activities,user_birthday,user_checkins,user_education_history,user_events,user_groups,user_hometown,user_interests,user_likes,user_location,user_notes,user_online_presence,user_photo_video_tags,user_photos,user_relationships,user_relationship_details,user_religion_politics,user_status,user_videos,user_website,user_work_history,email,read_friendlists,read_insights,read_mailbox,read_requests,read_stream,xmpp_login,manage_friendlists,manage_notifications,status_update,offline_access,publish_checkins,publish_stream,rsvp_event,manage_pages
I have accepted all grant access scopes and I have successfully connected and get the users data I have save into the database the info of users available pages:
page id and page access token
Whe I am posting a test message It say's : #200) The user hasn't authorized the application to perform this action
here is my login script for fb:
window.fbAsyncInit = function() {
FB.init({
appId:'MY_APP_ID', cookie:true,
status:true, xfbml:true,oauth : true
});
};
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
//FB.Event.subscribe("auth.logout", function() {window.location = '/logout'});
$('#facebook_login').click(function(e) {
FB.login(function(response) {
if(response.authResponse) {
parent.location ='http://mywebsite.com/users/oauth_fb';
}
},{scope: 'user_about_me,user_activities,user_birthday,user_checkins,user_education_history,user_events,user_groups,user_hometown,user_interests,user_likes,user_location,user_notes,user_online_presence,user_photo_video_tags,user_photos,user_relationships,user_relationship_details,user_religion_politics,user_status,user_videos,user_website,user_work_history,email,read_friendlists,read_insights,read_mailbox,read_requests,read_stream,xmpp_login,manage_friendlists,manage_notifications,status_update,offline_access,publish_checkins,publish_stream,rsvp_event,manage_pages'});
});
After connecting facebook account I will logout automatically my facebook account with my script:
<script>
window.fbAsyncInit = function() {
FB.init({
appId:'MY_APP_ID', cookie:true,
status:true, xfbml:true,oauth : true
});
FB.Event.subscribe('auth.authResponseChange', function(response) {
if (response.status === 'connected') {
FB.logout(function(response) {
window.location = '';
});
}
});
};
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = \"//connect.facebook.net/en_US/all.js\";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
And here is my script for posting (this is for offline posting so user already logged out on facebook):
$oauth_uid = 'PAGE_ID_FROM_DB';
$oauth_token = 'PAGE_TOKEN_FROM_DB'
$post_url = '/'.$oauth_uid.'/feed';
if ($oauth_uid) {
$msg_body = array(
'access_token' => $oauth_token,
'message' => 'tesing post to my page',
);
try {
$postResult = $facebook->api($post_url, 'post', $msg_body );
} catch (FacebookApiException $e) {
echo $e->getMessage();
}
}
How to fixed this issue ? I don't see anything wrong with my script , why I can post to my personal facebook account while I can't post on my facebook page ?
Please help..
Thank you.