Get Account User Id FBML - facebook

I'm new to the facebook app making and I'm just wondering how I can get the user who enabled the app (the one using it)'s user id.
Thanks

Like this:
$facebook = new Facebook('API', 'SECRET');
echo $facebook->user;

The new PHP SDK is available here: http://github.com/facebook/php-sdk. It has an example that shows how to get the user id and profile: http://github.com/facebook/php-sdk/blob/master/examples/example.php.

Related

Get link to profile in Socialite?

I am trying to get a way to unique identify a Facebook profile using socialite for laravel. I have looked through all of their documentation but it doesn't seem like I can find anything
does anyone know how I am unique identify their profile without it being changed / spoofed like an ID or link to profile that never changes? I have tried doing http://facebook.com/profile.php?id=ID_HERE but no luck
For facebook just add id:
// user got from socialite
$user = Socialite::driver('facebook')->user();
// link to his profile
$userlink = 'https://facebook.com/' . $user->id;

Ionic with Backand social login: profile picture

I'm developing an application with ionic and Backand and I'm using the sign in with social accounts with the Backand service.
The social login process is OK, but I want to get the ID from Facebook and Google plus in order to get the profile picture.
I was talking with the support of Backand and I know that in Security and Auth there is an action "beforesocialSignUp" and I have not commented the line to get the data:
'use strict';
function backandCallback(userInput, dbRow, parameters, userProfile) {
// get facebook id and put in fuid field that you need to add to your user object
userInput.fuid = parameters.socialProfile.additionalValues.id;
// get gender from facebook and put in gender field that you need to add to your user object
// userInput.gender = parameters.socialProfile.additionalValues.gender;
}
And I have created the fuid field in my user object, but, when I make a login with Facebook or Google+ It doesn't save nothing. The login is OK but I can't get the ID data.
Any idea?
I had exactly the same problem.
The solution was to set the where condition of the BeforeSocialSignUp function from false to true.
This is nowhere in the documentation explained.
It took me 3 day ro figure this out :-(
Now the login works as expected and the fuid field gets assigned.
My next step is to get the profile picture from the FB Account, but therefore I have to make an API request to facebook with a user access token which I dont know how to get from backand.

Generate access token Instagram API, without having to log in?

So I am building a restaurant app and one of the features I want is to allow a user of the app to see photos from a particular restaurant's Instagram account.
And I want a user to be able to see this without having to login to their Instagram account, so they shouldn't even need an Instagram account for this to work.
So I have read this answer How can I get a user's media from Instagram without authenticating as a user?
And I tried what it said and used the client_id(which I recieved when I registered my app using my personal Instagram account), but I still get an error back saying :
{
meta: {
error_type: "OAuthAccessTokenException",
code: 400,
error_message: "The access_token provided is invalid."
}
}
The endpoint I am trying to hit is :
https://api.instagram.com/v1/users/search?q=[USERNAME]&client_id=[CLIENT ID]
So do I absolutely need an access token for this to work(and thus have to enforce a user to log in) ?
If I do, then is there way to generate an access token somehow without forcing the user log in?
I believe there is a way around this, as the popular dating app Tinder has this desired functionality I am looking for, as it allows you to see photos from people's Instagram account without having to log in! (I have just verified this 5 minutes ago!)
Any help on this would be much appreciated.
Thanks.
Edit April 2018: After facebook privacy case this endpoint is immediately put out of service. It seems we need to parse the JSON embedded in <script> tag directly within the profile page:
<script type="text/javascript">window._sharedData = {"activity_counts":...
Any better ideas are welcome.
You can use the most recent link
GET https://www.instagram.com/{username}/?__a=1
to get latest 20 posts in JSON format. Hope you put this to good use.
edit: other ways aren't valid anymore:
https://www.instagram.com/{username}/media/
Instagram used to allow most API requests with just client_id and without access_token, the apps registered back in the day still work with way, thats how some apps are able to show instagram photos without user login.
Instagram has changes the API specification, so new apps will have to get access_token, older apps will have to change before June 2016.
One way you can work around this is by using access_token generated by your account to access photos. Login locally and get access_token, use this for all API calls, it should not change, unless u change password,if it expires, regenerate and update in your server.
Since the endpoints don't exist anymore I switched to a PHP library -
https://github.com/pgrimaud/instagram-user-feed
Installed this lib with composer:
composer require pgrimaud/instagram-user-feed "^4.0"
To get a feed object -
$cache = new Instagram\Storage\CacheManager();
$api = new Instagram\Api($cache);
$api->setUserName('myvetbox');
$feed = $api->getFeed();
Example of how to use that object -
foreach ($feed->medias as $key => $value) {
echo '<li><img src="'.$value->thumbnailSrc.'"></li>';
}

Facebook C# SDK - Api.Get("me/events") not returning events

I've tried to return the user events but with no success.
FacebookApp app = new FacebookApp();
dynamic eventos = app.Api("me/events");
In this example, am i doing something wrong? The user is already authenticated (i can get his information, posts of wall, etc).
Thanks
You must ask for the "user_events" extended permission. http://developers.facebook.com/docs/authentication/permissions/

Get Facebook username

I am trying to write a small application to learn about developing for Facebook and I was trying one basic command, to say (Welcome, user_name).
I used:
Welcome, <fb:name uid='<?php echo $user; ?>' useyou='false' possessive='true' />!
but it did not work, do you know what should i use?
Are you doing this through a canvas application or Facebook Connect?
In either case, it's probably one of two issues: Either (A) the Facebook object is being fired up with the wrong api key or secret, or (B) you haven't authorized the application, so there's no UUID coming through.
Calling this before that code of yours should fix both:
$facebook = new Facebook(YOUR_API_KEY,YOUR_SECRET_CODE);
$user = $facebook->require_login();