check if user likes a page with Laravel Socialite - laravel

I'm using Laravel Socialite to make users log in to my site. I've managed to do that and store the user's data.
But now i want to find out how i can check if that particular user (when logged in) has liked my facebook page.
Thank you so much!

Socialite is a package that handles authentication using Facebook, Twitter, LinkedIn, Google, GitHub and Bitbucket. It does not have the ability to retrieve information regarding user likes.
You can use the facebook-php-sdk inorder to get the pages that user has liked. The code below is from the facebook graph api documentation on how to get the pages that the user has liked.
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'GET',
'/{user-id}/likes'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */

Related

Get email from twitter OAuth2

I am using Socialite in Laravel to login with Twitter.
I know that not all twitter users have an email attached to their account, but for my application the user does need an email address. I am fine to block logins from people who do not have an email attached, but at the moment every user does have the email field set to null.
I am using this function to redirect to twitter:
return Socialite::driver($provider)->redirect();
I have already tried using scopes like this:
return Socialite::driver($provider)->scopes(['email'])->redirect();
But twitter is the only provider that does not allow scopes.
The callback returns the email address for other providers like facebook and google, but there seems to be something that I am missing while using twitter.
For OAuth1 there was a setting somewhere to enable the option to return the email field aswell, but since twitter accepts OAuth2 I can not find this setting anymore in the Twitter developers panel.
Any help would my appreciated since most of the information about this topic is outdated.
The solution was found in the twitter developers dashboard.
First of all go to the settings of your app.
Then you have to fill in a link to your privacy policy & terms page.
After that also enable OAuth 1.0 en then an option pops up to also receive the email address from the user that is trying to log in.
Twitter's new Oauth 2.0 user authentication does not currently (at the time of writing this answer) provide access to the user's email address, and will require an additional scope to be added. This is on the Twitter API roadmap and is a known feature request.
You can still use OAuth 1.0A and set the option to request the user's email address.

How do I verify if someone is a facebook user

I'm building a laravel app that is using a admin user registration approval system. Once an admin approves the registration, I'd like the users to verify on their profile page that they are members of facebook and linkedin. I see a bunch of stuff about user creation and login, but not about verification. Can someone please point me in the right direction?
If you are familiar with Laravel Socialite, this can be achieved...
Once your users are logged in and approved by admin, you could add a facebook button to use the Socialite login functionality, but with some custom work.
In SocialAuthController.php
Find the handleFacebookCallback method
In my example i have the method named as handleProvider, but it works just the same
public function handleProviderCallback($provider)
{
// First we are going to get the user data from facebook
$social_user = Socialite::driver($provider)->fields([
'name', 'email'
])->user();
//Now we make the logic
if (Auth::check()) { //if the user is logged in
$userID = Auth::user()->id; //then we get the user ID
$user = User::where('id', $userID)->first(); //Prepare the model for update
//And finally we just start to update each field in DB (you need to create this fields)
$user->fb_email = $social_user->email;
$user->avatar = $social_user->avatar;
$user->fb_id = $social_user->id;
$user->save();
return $this->authAndRedirect($user); // This is to redirect the user
}
}
With this you can make the users link their accounts in your app with facebook...
But keep in mind that also you'll need to handle with the else, the rest of the code for creating a new account if you are going to allow users to register with facebook. Otherwise, you only need to add the facebook button in the profile page of your users to link with their respective fb account.
The button can be like this:
<i class="fa fa-facebook-square"></i>
also you would need to configure socialite as and be familiar with this first.

Lumen Login tutorial for web app no API?

I'm using lumen to make a website. I choose it because it has been told that lumen is a stunningly fast php micro framework. I need login guide. I have created login form and received data, and validated them. Now I need to check user credinals and login user. Auth::attempt($usercredinals) is not working. Fatal error with method not found is thrown. Is there any idea to use middleware and create routes that automatically login user and make available through Auth::user() method.
Thanks in Advance.
I have not found full tutorial or documentation for authentication.

Laravel Stormpath Social Login Error

I am using Laravel 5.1 and Stormpath for User management.
I followed this documentation to implement google login
Configuring Your Social Provider = DONE
I created project in Google Console and in “Authorized redirect URIs” I've added
https://{DNS-LABEL}.apps.stormpath.io/authorize/callback
Create a Stormpath Social Directory = DONE
Initiate Social Login - In my form when I click on Google Sign In it redirects to
https://{DNS-LABEL}.apps.stormpath.io/?response_type=stormpath_token&
account_store_href=https://api.stormpath.com/v1/directories/{id}
&redirect_uri=https%3A%2F%2Flocalhost
and returns
{"status":404,"message":"Resource not found."}
As per this documentation:
The user clicks on a “Login with Google” link pointing at your application’s /authorize endpoint
Stormpath handles the login to Google and redirects the user back to your app with a Stormpath Token JWT response
What am I doing wrong? Why isn't stormpath redirecting to the google login page?
It looks like the URL that you are creating is missing the /authorize part. If you update your URL to be
https://{DNS-LABEL}.apps.stormpath.io/authorize?response_type=stormpath_token&
account_store_href=https://api.stormpath.com/v1/directories/{id}
&redirect_uri=https%3A%2F%2Flocalhost
It should begin working for you.
In a future release of the PHP SDK (which powers the laravel integration), we will be able to generate this URL for you.
If you are using our Stormpath/Laravel integration, the views provided will automatically handle social logic for you. If you are doing this from scratch, it may be worth a look at https://github.com/stormpath/stormpath-laravel
-Brian

magento SOAP API

How do i get the cart details of an existing user using Magento SOAP API.
I have an e-commerce Application based on Magento. There is already a desktop webpage for this e-commerce application. My use case is this -
-> User logs in from desktop webpage and then adds an item to the cart
-> User now logs in with the same credential from mobile
I want to be able to show the item that is being added from desktop page. But right now i don't see any SOAP API which helps me query any existing cart info for an user.
Note : I am trying this from an Android Application. So please suggest anything that i can with the SOAP API's
you can get cart information using magento api. using SOAP V1 you can get cart info like that
$client = new SoapClient('http://magentohost/api/soap/?wsdl');
// If somestuff requires api authentification,
// then get a session token
$session = $client->login('apiUser', 'apiKey');
$result = $client->call($session, 'cart.info', $quoteid);
var_dump ($result);
OR you can use SOAP V2. Just check this out for whole information.
http://www.magentocommerce.com/api/soap/checkout/cart/cart.info.html

Resources