I am trying to get FB user's full name using the access_token. I have the access_token with me but I am not sure how I can use it to access user information.
I have read the documentation and it says to get more user info we can use:
https://graph.facebook.com/userid?access_token=...
So, does this mean I need to use cURL to get response from this URL?
Btw, I am using PHP.
Thanks.
Accesstoken you can use for getting the information of the user which is necessary. Also if you have asked offline_access permission from user, you can store this accesstoken in your database and can get the user information even if he not logged in with facebook. That means, from next time you automtically get the information using this token.
Related
i am trying to implement the 'Like' operator by using access tokens from user.
if a user Login in my site using Facebook i will store access token from that user and then using that access token how i can make like on another people's status or photo?
Is it possible using Facebook app ? if yes,can you give me any link to know more about it or just give me brief about it.
Thank you
You can like a photo by issuing a HTTP POST request to PHOTO_ID/likes connection with the publish_stream permission. No parameters necessary.
If the write is successful, you get a boolean response as return.
Link:https://developers.facebook.com/docs/reference/api/photo/
Similarly for liking a status use OBJECT_ID/likes
Hi guys I understand how to retrieve the ACCESS TOKEN by requesting the permission to access a client's instagram but I'm trying to avoid exactly that.
I need to be able to get someone's last picture without requesting to authenticate on instagram to the client.
There has to be a way with the api to fetch that picture while using OUR instagram account and not the client's instagram is there not?
I don't want to have to hard code a connection and html scraping!
Please enlighten me and sorry for my bad english!
TL;DR: I want to use my client id, client secret or username/password of my instagram account to view another user on instagram's picture!
You can use your access_token to access other user's instagram photo feed API. As long as that user is not private. You cannot use client_id for accessing any user information, you have to authenticate and use access_token. This API call will work for, just replace the user_id you want to access and use your access_token.
https://api.instagram.com/v1/users/USER_ID/media/recent/?access_token=ACCESS-TOKEN
I am using LinkedIn API.
I have done all process to retrieve access token.
but never show anywhere to remove/revoke access token from the LinkedIn.
Please Help.!
Once you store the secret in your DB simply delete it and the access will be revoked.
I believe that if you wish for the user to revoke access to your app the user must to go linkedin and do it, much like Facebook.
As confirmed here: http://developer.linkedin.com/forum/how-really-revoke-apps-oauth-access-token linkedin does not have a programmable API for what you wanna do.
But before you remove it from DB you can invalidate the token which is like an extra step to take by cURLing https://api.linkedin.com/uas/oauth/invalidateToken with your token I believe.
Edit
As #Paul corrects, it is actually quite important to invalidate the tokens with LinkedIn. So doing that and then removing from DB is, as he says, the correct way.
I'd just like to ask about a problem I'm facing with Facebook Graph API.
I've connected to Facebook successfully, stored the user ID, and user access_code into my DB
Now when viewing the site I'm building, it's using the access_token stored in my database, but doesn't show my facebook statuses....because the "session has expired"....
Is there anyway I can regenerate the access_token?
Thanks
Example:
$status = 'https://graph.facebook.com/'.$userId.'/statuses?limit='.10.'&access_token='.$app_token;
User access tokens last only 1-2 hours. There is a technique to get a 60 day token for your use. It is explained here: http://dominicminicoopers.blogspot.com/2012/03/facebook-access-tokens-and-offline.html Remember to get this extended access token prior to the short-lived access token expiring. You must pass in a valid working user access token to pass to it. Do this serverside, not clientside because you have to use your app secret.
https://graph.facebook.com/oauth/access_token?
client_id=[APP_ID]&
client_secret=[APP_SECRET]&
grant_type=fb_exchange_token&
fb_exchange_token=[EXISTING_NON-EXPIRED_USER_ACCESS_TOKEN]
Remember to ask for the user_status permission when prompting the user. See: http://developers.facebook.com/docs/authentication/permissions/#user_friends_perms
You cant regenerate it, but you can get a new one by having the user go through the oauth process again, it will return a new token - https://developers.facebook.com/docs/authentication/
You can try to get a long lived token. That will allow you to access the status even when the user is not loged in.
See here
i'm trying to get user's public information (name, photo, gender, profile link).
as i seen in https://developers.facebook.com/docs/reference/api/user/ to get this information i don't need any access token.
i'm using the facebook.php sdk to connect to facebook as written in the example:
https://github.com/facebook/php-sdk/blob/master/examples/example.php
for some reason it always ask me to get access token for basic information, although all i need is public information...
how can i get the public information only with no access token ?
To get public information without an access token, just go to the graph itself.
Try https://graph.facebook.com/4 for an example.
To get the information from the user, the user has to grant you their information. This is done by them logging in to your site via their facebook account. By implementing the Facebook PHP SDK on your site you can use the function getLoginUrl() to provide the login url to the users. When they've logged in, they'll be sent back to your site with their id available. You can then use the api() method to query the graph for the information you want. Remember that for all information that is not public, you'll need to ask for privileges when they connect their account.
If you don't have their access token, you can't get information from them. You'll need to know who the users are in order to query for information. But once you've got their access token you can store basic information in your own database so that you don't have to query the graph next time.