social sharing using oauth2.0 and oauth1.0
Post on 08-Jul-2015
86 Views
Preview:
DESCRIPTION
TRANSCRIPT
Social Share
Objective
To study system that enable us to
• fetch user Info from social website
• share content on user’s account after authorization from him.
• Get long term access to user’s account for sharing content using cron without asking for his permission every time .
Social Share
ArchitectureUser authorizes system once to
share content on behalf of him
Save Access Token
Share Content
Social Share
Functionalities ProvidedSocial Share
Class StructureSocial Share
Sequence flow: Fetch User InfoSocial Share
Sequence Flow : Share ContentSocial Share
Sample Code• Get Authorization Uri: For OAuth 2.0
• Get Authorization Uri: For OAuth 1.0(twitter)
• Fetch User Info
$linkedInInstance= AutoSharing::getLinkedInInstance(APP_ID, APP_SECRET); $linkedInAutherizationUrl=$linkedInInstance->getAuthorizeUrl(REDIRECT_URL);
$twitterInstance= AutoSharing::getTwitterInstance(APP_ID, APP_SECRET); $requestToken=$twitterInstance->getRequestToken(REDIRECT_URL); $_SESSION["twitterOAuthToken"] = $requestToken['oauth_token'];$_SESSION["twitterOAuthSecret"] = $requestToken[‘oauth_token_secret'];
$twitterAutherizationUrl=$twitterInstance->getTwitterAuthorizationUrl( $ requestToken['oauth_token'],$ requestToken['oauth_token_secret']);
Social Share
Contd..
• Fetch User Info: For OAuth 2.0
• Fetch User Info: For OAuth 1.0
$socialInstance= AutoSharing::getTwitterInstance(APP_ID, APP_SECRET); $socialInstance->setOAuthToken ($_SESSION["twitterOAuthToken“] );$socialInstance->setOAuthSecret($_SESSION ["twitterOAuthSecret“]); $accessToken=$socialInstance->getAccessToken($authorizationCode, REDIRECT_URL); $userProfileArr=$socialInstance->getUserInfo($accessToken);
$linkedInInstance= AutoSharing::getLinkedInInstance(APP_ID, APP_SECRET); $linkedInAutherizationUrl=$linkedInInstance->getAuthorizeUrl(REDIRECT_URL);
Social Share
Contd..
• Share Job
NOTE:OAuth2.0 : Facebook, LinkedInOAuth1.0 : Twitter
$socialInstance= AutoSharing::getLinkedInInstance(APP_ID, APP_SECRET);$updateId= $socialInstance-> shareUrl($accessToken,$updateUrl);
Social Share
Why use this?
• Simple and Easy to Integrate
• No need to look out for API of different social network , hence save time.
• Common exceptional handling
• Easily extendible and use for other social platforms.
Social Share
THANKS
Social Share
top related