PHP sessions that have already been started – Stack Overflow
Notice: A session had already been started – ignoring session_start() 의 메시지의 경우
if(!isset($_SESSION))
{
session_start();
}
를 이용해결한다.
PHP sessions that have already been started – Stack Overflow
Notice: A session had already been started – ignoring session_start() 의 메시지의 경우
if(!isset($_SESSION))
{
session_start();
}
를 이용해결한다.
php – Undefined variable: $_SESSION – Stack Overflow
undefined variable: $_SESSION 의 경우 session_start()를 시작하지 않아서 생기는 문제.
Can you run in localhost an app that use Twitter OAuth? – Stack Overflow
-Add oauth_callback=http://localhost/return
as a parameter when you get request_tokens.
-Set your callback url in twitter app setting to http://127.0.0.1/ or
http://127.0.0.1/return
– authentication 의 과정은 3 legged authorizatin 을 이용한다. 이는 implementing sign in with twitter ( https://dev.twitter.com/docs/sign-twitter-resources ) 의 과정과 매우 비슷하다.
– 트위터 계정 sign in을 개발 application의 sign in 과정으로 그대로 이용하는 경우 ( https://dev.twitter.com/docs/sign-twitter-resources )
– data의 get,post 구체적 방법은 REST api를 이용한다.
( https://dev.twitter.com/docs/api/1.1 )
-다른 개발자가 제작한 library를 이용하는 경우 참조
– authentication 의 과정은 3 legged authorizatin 을 이용한다. 이는 implementing sign in with twitter ( https://dev.twitter.com/docs/sign-twitter-resources ) 의 과정과 매우 비슷하다.
– 트위터 계정 sign in을 개발 application의 sign in 과정으로 그대로 이용하는 경우 ( https://dev.twitter.com/docs/sign-twitter-resources )
– data의 get,post 구체적 방법은 REST api를 이용한다.
( https://dev.twitter.com/docs/api/1.1 )
-다른 개발자가 제작한 library를 이용하는 경우 참조
twitter Implementing Sign in with Twitter | Twitter Developers
The browser and mobile web implementations of Sign in with Twitter are based off of OAuth. This page demonstrates the requests needed to obtain an access token for the sign in flow. For information on implementing Sign in with Twitter for iOS, see Integrating with Twitter on iOS.
To use the “Sign in with Twitter” flow, please go to your application settings and ensure that the “Allow this application to be used to Sign in with Twitter?” option is enabled.
This page assumes that the reader knows how to sign requests using the OAuth 1.0a protocol. If you want to know how to sign a request, read the Authorizing a request page.
If you want to check the signing of the requests on this page, the consumer secret used is:
L8qq9PZyRg6ieKGEKhZolGC0vJWLw8iEJ88DRdyOg
This value has been disabled and will not work for real requests.
To start a sign in flow, your application must obtain a request token by sending a signed message to POST oauth/request_token. The only unique parameter in this request is oauth_callback, which must be a URL-encoded version of the URL you wish your user to be redirected to when they complete step 2. The remaining parameters are added by the OAuth signing process.
Example request (Authorization header has been wrapped):
POST /oauth/request_token HTTP/1.1 User-Agent: themattharris' HTTP Client Host: api.twitter.com Accept: */* Authorization: OAuth oauth_callback="http%3A%2F%2Flocalhost%2Fsign-in-with-twitter%2F", oauth_consumer_key="cChZNFj6T5R0TigYB9yd1w", oauth_nonce="ea9ec8429b68d6b77cd5600adbbb0456", oauth_signature="F1Li3tvehgcraF8DMJ7OyxO4w9Y%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1318467427", oauth_version="1.0"
Your application should examine the HTTP status of the response. Any value other than 200 indicates a failure. The body of the response will contain the oauth_token, oauth_token_secret, and oauth_callback_confirmed parameters. Your application should verify that oauth_callback_confirmed is true and store the other two values for the next steps.
Example response (response body has been wrapped):
HTTP/1.1 200 OK Date: Thu, 13 Oct 2011 00:57:06 GMT Status: 200 OK Content-Type: text/html; charset=utf-8 Content-Length: 146 Pragma: no-cache Expires: Tue, 31 Mar 1981 05:00:00 GMT Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0 Vary: Accept-Encoding Server: tfe oauth_token=NPcudxy0yU5T3tBzho7iCotZ3cnetKwcTIRlX0iwRl0& oauth_token_secret=veNRnAWe6inFuo8o2u8SLLZLjolYDmDP7SzL0YfYI& oauth_callback_confirmed=true
The next step is to direct the user to Twitter so that they may complete the appropriate flow, as described in Browser sign in flow. Direct the user to GET oauth/authenticate, and the request token obtained in step 1 should be passed as the oauth_token parameter.
The most seamless way for a website to implement this would be to issue a HTTP 302 redirect as the response to the original “sign in” request. Mobile and desktop apps should open a new browser window or direct to the URL via an embedded web view.
Example URL to redirect to:
https://api.twitter.com/oauth/authenticate?oauth_token=NPcudxy0yU5T3tBzho7iCotZ3cnetKwcTIRlX0iwRl0
The sign in endpoint will behave in one of three ways depending on the user’s status:
The possible states for the sign in interaction are illustrated in the following flowchart:
Upon a successful authentication, your callback_url would receive a request containing the oauth_token andoauth_verifier parameters. Your application should verify that the token matches the request token received in step 1.
Request from client’s redirect (querystring parameters wrapped):
GET /sign-in-with-twitter/? oauth_token=NPcudxy0yU5T3tBzho7iCotZ3cnetKwcTIRlX0iwRl0& oauth_verifier=uw7NjWHT6OJ1MpJOXsHfNxoAhPKpgI8BlYDhxEjIBY HTTP/1.1 Host: localhost User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.5 (KHTML, like Gecko) Chrome/16.0.891.1 Safari/535.5 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Referer: http://localhost/sign-in-with-twitter/ Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3
To render the request token into a usable access token, your application must make a request to the POST oauth/access_token endpoint, containing the oauth_verifier value obtained in step 2. The request token is also passed in the oauth_token portion of the header, but this will have been added by the signing process.
Example request (Authorization header wrapped):
POST /oauth/access_token HTTP/1.1 User-Agent: themattharris' HTTP Client Host: api.twitter.com Accept: */* Authorization: OAuth oauth_consumer_key="cChZNFj6T5R0TigYB9yd1w", oauth_nonce="a9900fe68e2573b27a37f10fbad6a755", oauth_signature="39cipBtIOHEEnybAR4sATQTpl2I%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1318467427", oauth_token="NPcudxy0yU5T3tBzho7iCotZ3cnetKwcTIRlX0iwRl0", oauth_version="1.0" Content-Length: 57 Content-Type: application/x-www-form-urlencoded oauth_verifier=uw7NjWHT6OJ1MpJOXsHfNxoAhPKpgI8BlYDhxEjIBY
A successful response contains the oauth_token, oauth_token_secret parameters. The token and token secret should be stored and used for future authenticated requests to the Twitter API. To determine the identity of the user, use GET account/verify_credentials.
Example response (response body has been wrapped):
HTTP/1.1 200 OK Date: Thu, 13 Oct 2011 00:57:08 GMT Status: 200 OK Content-Type: text/html; charset=utf-8 Content-Length: 157 Pragma: no-cache Expires: Tue, 31 Mar 1981 05:00:00 GMT Cache-Control: no-cache, no-store, must-revalidate, pre-check=0, post-check=0 Vary: Accept-Encoding Server: tfe oauth_token=7588892-kagSNqWge8gB1WwE3plnFsJHAZVfxWD7Vb57p0b4& oauth_token_secret=PbKfYqSryyeKDWz4ebtY3o5ogNLG11WJuZBc9fQrQo