accessing basic information with now access token - php

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.

Related

Get user information using access_tokens (not using facebook APIs)

I have successfull requested an access_token through manual login system construction. Please keep in mind I'm not using facebook php login API or javascript SDK. In the access token I asked permission to obtain the public profile and user_friends who also use my app. I have obtained public information using file_get_contents("https://graph.facebook.com/me?$access_token"); and I got the profile link, the name, the gender, etc, but how can I obtain the user_friends as mentioned above and how exactly do I manage context with the access token to obtain those informations? I don't understand how to use context with the file_get_contents above too...

Is it possible to register and log in my users with the Soundcloud API as opposed to just connecting to it?

Basically, I'd like my users to be able to register and log into my site using their Soundcloud accounts (much like Google or Facebook).
But I'm following the login flow from their docs (http://developers.soundcloud.com/docs#authentication), and I understand how to redirect them to the Soundcloud connect screen to authorize my app. And from that, I get a code that I can exchange for an access token. But after that the docs state this:
You should now store the access token in a database. Associate it with
the user it belongs to and use it from now on instead of sending the
user through the authorization flow.
So they're assuming that I already have registered users who then connect to Soundcloud through some other function of my app. But what I want, is for them to be able to create their account from their Soundcloud user info. I think this is initally possible, but when they return to log in again, I need that access token to identify them. But I can't get that access token without sending them through the auth flow again.
I'm guessing what I want to do can't be done, but it's also possible I'm overlooking something. Any help would be appreciated!
I've done this with IMGUR OAuth2 API. After you get the access token, make a new request to their /me endpoint. This way, you'll have the SoundCloud id for that particular user. Now you can check if you already saved this user in your database. If you have, just save the new token to make sure this user has granted your app access to their SoundCloud. I'm not sure if I were clear enough. Let me know if you need any further help .

Post offline/without login using Facebook SDK PHP

I need implement a functionality in save/update function, of my customers system:
In each save/update, I need get this informations, and send to a Facebook Page (every the same Page).
But my problem is: this system is used by a lot users, and some users do not have a Facebook account, so: How can I post in same Page without login?
I know the offline_access are removed, so, what the best solution in this situation?
I don't find any way, to get the Page Access Token
I create some APP in my personal account of Facebook, but, when I try post in this Page, I get a access unauthorized for this user/app
Sorry for my english.
For you to post updates on to the Page's feed there are few things you would require
An User with administrative or content publishing permission to atuhorize your application with manage_pages Extended permissions. If you have implemented the login, you can add these permissions there, or alternatively you can use Graph Explorer with your application selected to get started.
After you have been authorized then you can retrieve the Page Access Token by querying /me/accounts which would return data as shown in this documentation. You can then utilize the access token you retrieve for the corresponding page to do your job of posting updates.

How to use access_token (of Facebook Graph API)?

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.

Google Friendconnect: How to fetch profile data when the user id is known

I am integrating GFC with my web app (PHP). In this app I have a list of user IDs and I need to fetch their profile details like their display name, profile pic url etc. using a HTTP call.
For example, I am trying to fetch data of user with id: $userId = 1234567
If a viewer (need not the user with above id) is logged in, I am able to fetch data by making a call to following URL.
http://www.google.com/friendconnect/api/people/$userId/#self?fcauth=$fcauth
But, if viewer is not logged in, the above URL replies the following
Anonymous requests are not allowed to fetch data
Error 401
I would like to know what URL should be used to fetch the user data even if no one is logged in.
Thanks!!
The fcauth mechanism is designed for access while the user is online. The fcauth tokens expire fairly rapidly, and no guarantee is made about how long they're valid for. You should assume that they'll only work while the user is online.
If you need offline access, you need to use OAuth. OAuth tokens are valid until manually revoked.
The API call you're making is the correct one, you just need to do it with OAuth instead of fcauth.

Categories