LinkedIn Oauth scope issue with PHP library - php

I have been trying to implement the new scope features that were recently added to the LinkedIn API. I am currently using the "simple-linkedinphp" library for as my LinkedIn oauth lib (http://code.google.com/p/simple-linkedinphp/ ).
Following the directions on the LinkedIn docs, I added the "scope" param to my request token URL as such:
const _URL_REQUEST = 'https://api.linkedin.com/uas/oauth/requestToken?scope=r_basicprofile+r_emailaddress';
However, this had little effect. I still get the same o-auth dialogue as before without any additional permissions for the e-mail address. Anyone get this working correctly in PHP yet? Any help here would be appreciated.

You need to create new Application API keys and use those to see the updated authentication screens.

Related

Youtube Video Uploading Api With Oauth by using api key

When I search YouTube video uploading API all the example I see is based on Oauth and its use client id and secrete key. However I have seen using api key, but code not found any were i want it will use in core php .. by curl...
So if anyone has code and suggestion please help me..
thanks.
As you can see from the documentation Videos: insert it requires authentication and authorization using the following scopes.
Authorization
This request requires authorization with at least one of the following
scopes (read more about authentication and authorization).
Scope https://www.googleapis.com/auth/youtube.upload
https://www.googleapis.com/auth/youtube
https://www.googleapis.com/auth/youtubepartner
https://www.googleapis.com/auth/youtube.force-ssl
API keys are used for accessing public data only.

Google plus sign in : How to get the user email?

I'm using this code https://github.com/google/google-api-php-client the user-example.php in the examples folder, to make some tests on Google plus signin.
Everything worked well, except one thing. After the connection, i obtained this url :
http://MYURL/?code=4/vt_b0DsUU91UOYkB3ozIp-ZLITiL2irzaaUzyvtdph4.4gAL4kfDZGUVJvIeHux6iLafIxOglAI
My question is, where can i get the user email ?
Thanks
TL;DR: Fully working solution: Get Userinfo from Google OAuth 2.0 PHP API
You're using offline flow which is described in details here: https://developers.google.com/accounts/docs/OAuth2WebServer#handlingtheresponse
At this point you got code.
vt_b0DsUU91UOYkB3ozIp-ZLITiL2irzaaUzyvtdph4.4gAL4kfDZGUVJvIeHux6iLafIxOglAI
This code needs to be exchanged for access_token.
Exchanging code for access token using Google Library: https://github.com/google/google-api-php-client/blob/master/examples/user-example.php#L66
With access_token you can send api requests.

List all Google Apps Profiles on PHP Site

I am trying to get a list of all Google Apps users of a domain onto a public PHP website (without visitors of the site needing to login or do anything). I have a basic understanding of what needs to happen but can't quite piece it all together. It can't be as hard as it seems to me... could it?
Authentication and Authorization:
I'm pretty sure it needs to use OAuth 2.0 ... but am unsure whether it needs 2 legged or 3 legged. I got another section of the site working with ClientLogin but that won't pull in Google Apps profiles, only user's first and last names (I need the other profile fields). I have set up the API access within the account and have that side of things all set (I believe).
I have found this page, which shows how to construct a URL request to get all Profiles (in every language except PHP of course) but don't understand how to implement this.
http://code.google.com/googleapps/domain/profiles/developers_guide.html
I also tried this example but it just gives me a 401 after I enter the credentials. http://gdatatips.blogspot.com/2008/11/2-legged-oauth-in-php.html
I don't know which frameworks or includes are needed to accomplish this either. I have tried zend, OAuth.php and a whole bunch of other bootstraps... but keep getting lost as to what each is doing.
If someone could help me by outlining:
Which files/framework I need to upload and include as a bootstrap
What variables within those files I need to update with the Google credentials
How I integrate the Google Profiles "Retrieve all Profiles" request with PHP
An ELI5 (explain it like i'm 5) overview would be very much appreciated... I'm sorry for my apparent incompetence, but I have been reading articles for nearly a week and have not gotten anywhere.
Thank you in advance for any help provided.
Good question.
You'll need to implement the Google OAuth 2.0 process as it's described here (experimental?), because someone (you) will need to give your app the initial permissions to access Google Apps API. Steps are:
Register your domain with google (don't remember the link)
Redirect/send browser to an authentication url: https://accounts.google.com/o/oauth2/auth, with the appropriate request params (see the first link). You'll need access_type=offline, your scope would be https://apps-apis.google.com/a/feeds/user/
Get a code back, then exchange for a refresh_token, an access_token, and a value specifying when the access_token will expire. Store these in a database
Whenever you need to make an API call, check if your access_token has expired or not, and refresh when necessary, which is what the refresh_token is for. The refresh_token is valid as long as you don't revoke the access you gave to the app.
OAuth Playground helps a lot. Good luck.

What is the latest Facebook PHP API?

Seemingly it supposed to be https://github.com/facebook/php-sdk/. However, I am suspicious either it so because getLoginUrl method generates not the type of URL that is described in http://developers.facebook.com/docs/authentication/.
So I was wondering which of these is outdated?
The PHP SDK that you linked is up to date. It is a client for the various Facebook APIs, including the Graph API, the "old" REST API, and others. Right now, getLoginUrl() does generate a URL that has been used for longer than the OAuth documentation has existed, but the end result will be the same for you. If you do have a problem with that login URL for some reason, you're free to implement authentication any way you like by replacing or extending the existing SDK logic.
Remember, APIs and SDKs are not the same thing. The PHP SDK is just one API client. Everything in the official FB docs should be considered up-to-date, as they've all been revamped this year.
OAuth based authentication and Graph Api for data are the latest ones.
http://developers.facebook.com/docs/authentication/
see this also:
http://developers.facebook.com/docs/reference/rest/

how can I fetch private tweets using a PHP application

I want to show my latest tweet in a web page. My tweets are private for some reason and I should login to Twitter. I know that the basic HTTP authentication was deprecated in August 2010. How can I provide authentication in my PHP code to fetch private tweets (or userTimeline if I'm not mistaken)?
I've searched but unfortunately didn't find anything useful! :( Thanks in advance for your help!
Jan, I heard about ZendFramework while I was searching for the answer but It's complicated for me.
I found the solution here that illustrates how I can use OAuth based on Abraham’s Twitter OAuth library.
The key note is that I stored my 'oauth_access_token' in a database or somewhere else immediately after first login via my twitter credential. Then I remove the code which allow users to login to twitter and reuse stored credential to fetch the latest tweet by using $user->status->text variable.
It's a geeky job. It maybe has some potential security flaws but I'm not sure! ;)
By the way, Thanks a lot for your reply, Jan! :D
Authentication to Twitter is done via OAuth. A pretty simple way to access your Twitter account with PHP is using the latest version of ZendFramework. It will be required to register your app on twitter, which allows you to generate an oauth token. This token can be used to access your private twitter feed.
See documentation of Zend_Service_Twitter and Zend_Oauth_Consumer.
Here http://framework.zend.com/manual/en/zend.oauth.introduction.html you will find a pretty good introduction of using Zend OAuth together with twitter (note that the address used in the $config array has to be api.twitter.com/oauth and NOT twitter.com/oauth )
However, you can also make your Tweets public in your twitter account settings (Settings -> Account -> Tweet Privacy -> Uncheck "Protect my tweets"). Then your tweets will be available on the public timeline (not at once, you may have to wait a bit).
Hope that helps!
-Jan

Categories