var message = 'test';
var picture = 'http://l.yimg.com/f/i/tw/ks/show/120604_mntl01.jpg';
var link = 'https://www.youtube.com/watch?v=BIl8Px1ds3c';
var name = 'great';
var description = 'des';
FB.api('/1437247769881131/feed', 'post', {message: message, picture: picture, name: name, description: description },function (response){
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
I tried posting a test message to my fan page wall , but it become a visitor post(on left)
How could i post to the wall , if i change my admin to fan page admin ,it pop up a dialog
[You're using Facebook as a Page]
[To continue, you'll need to switch from using Facebook as 談政宏 to using Facebook as 談政宏.]
So i change back to person admin , but i can only post a visitor post
How can I post as Page Admin ?
You just need to use a Page Token to post "as Page". Right now you are using a User Token so it will get posted "as User". Information about Access Tokens:
https://developers.facebook.com/docs/facebook-login/access-tokens
http://www.devils-heaven.com/facebook-access-tokens/
Related
I'm busy implementing Facebook login for my django site. I'm not sure if I'm on the right track or way off the ball at the moment. I have implemented the full code as seen in the FB doc example https://developers.facebook.com/docs/facebook-login/web. Basically inserted script on the template. I have the button and once logging in I have the "Welcome fetching your information" "successful login for Joshua Raphael" in my console.log.
How do I now obtain the required email, username and profile pic? Is it a part of the response object? Also if I have email login, is it possible to obtain the response email and check my current database to see if the user is already registered?
Prefer not to use pre-made django apps but if you highly recommend one I may try it.Thanks
I assume you are doing this:
FB.login(function(response) {
if (response.authResponse) {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Good to see you, ' + response.name + '.');
});
} else {
console.log('User cancelled login or did not fully authorize.');
}
});
you can console.log the response and see what all it contains, you will get the email, username and profilepic in it, also you can specify the fields if it is not there like this:
FB.api('/me', {fields: 'last_name'}, function(response) {
console.log(response);
});
more here
also make sure you have added email in the scope in login method. like this:
FB.login(function(response) {
// handle the response
}, {scope: 'public_profile,email'});
I am using javascript to access the GA cookie __utmz when a user hits the page. The problem I am having I am unable to get the information on the first page view. The user must either refresh or navigate to a second page before I can see the information.
Is it possible to grab this info on first page view. If there is specific parts of my code you would like to see please let me know.
You can only access __utmz after the callback from Google has completed. As long as you're using a newer (~1.6+?) version of jQuery, the following should work:
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_trackPageview']);
$.ajax({
url: ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js',
dataType: "script",
cache: true,
success: function() {
// Cookie reading code goes here
console.log(readCookie("__utmz"));
}
});
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 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*/
}
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
response.authResponse is null
i have developed one facebook page with apps,
what i want is whenever any user visit my page, the user is served by one popup message, the popup will disappear only when user click "like" button, if user has already liked the page, popup will not appear, to do this i have write following code
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
var user_id = response.authResponse.userID;
var page_id = "app_id";
var fql_query = "SELECT uid FROM page_fan WHERE page_id = "+page_id+"and uid="+user_id;
var the_query = FB.Data.query(fql_query);
the_query.wait(function(rows) {
if (rows.length == 1 && rows[0].uid == user_id) {
alert("liked the page");
popup.hide() // hide the popup as user has clicked like button
}
else {
alert("not liked ");
}
});
}
else if (response.status === 'not_authorized') {
}
else
{
alert("not logged in");
}
});
the above code works fine with only one FB user, one which is admin of this page, for all other user it returns response.status === 'not_authorized' status, so i'm unable to retrieve the user login information, because in this case i'm getting null response.authResponse
do anyone have any idea, how to check login status for all users, not for admin only...??
thanks.
If you are talking about a page tab app and all you want to know is the "like" status of the visiting user then all you have to do is parse the signed_request passed to your app. You can read more about using and parsing Signed Requests here.
In the signed_request there is a user object - the information you need is in that object.