Get link to profile in Socialite? - facebook

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;

Related

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>';
}

Get user's gender using the old Facebook SDK

As you know facebook has moved to api 2.4, and now I can't get the user's gender with my previous code.
$f1 = new Fb_ypbox();
$user_data = $f1->getUserData();
$fb_user_id = $user_data['id'];
$name = $user_data['name];
$gender = $user_data['gender'];
$birthday = $user_data['birthday'];
Now this code only gets the user id & the usre name & his profile picture.
Not the gender or his birth date (although I have the extended permission of user_birthday).
Is there any chance to update my code or any other code to get the user's public info (gender for example) which doesn't request any extended permissions?
I just know that now it's not just making the GET request for "/me", but I also should add the "?fields=gender" addition.. I just can't manage to add it to my current sdk code.
I have read Facebook's API documentation couple of times and I can't figure it out..
Thanks :)
First of all you need to supply a more detailed description like the version of that "Fb_ypbox" class you are using. Probably there is a new version available that deals with the declarative fields changes in the 2.4 API already.
Since you did not supply these information we can only make a guess:
Search for "//graph.facebook.com/me?" in all class files and add the fields=name,gender,...

Social Engine get user id from profile page

I'm trying to add some features to the users profile page, and for that I would need that users ID - just to clarify, it's not viewers ID I'm chasing, it's the ID of the user whose profile I'm viewing.
So, I used $subject = Engine_Api::_()->core()->getSubject('user'); and it returns a big object full of all kinds of data, but don't know how to extract user ID?
Anyone have a clue? (SocialEngine 4 is the platform I'm using)
this will get you the userid of the profile..
$profileownerid = Engine_Api::_()->core()->getSubject('user')->getIdentity();
I've figured it out: $subject_id = $subject->getIdentity(); and voila!

Get Account User Id FBML

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.