乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗
仭OAuth偺奣梫
乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗

OAuth偺奣梫偼丄埲壓偺儁乕僕偑夝傝傗偡偄偱偡丅
愭偵慡懱偺棳傟傪壗偲側偔偱傕摢偵擖傟偰偍偔偲丄僾儘僌儔儉傪攃埇偟傗偡偄偲巚偄傑偡丅

OAuth僾儘僩僐儖偺拞恎傪偞偭偔傝夝愢偟偰傒傞傛
http://d.hatena.ne.jp/yuroyoro/20100506/1273137673

乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗
仭PHP偱偺OAuth
乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗

堦偐傜張棟傪彂偔偲戝曄側偺偱丄PEAR偺HTTP_OAuth_Consumer傪巊偭偰偄傑偡丅
HTTP_OAuth_Consumer偼丄僟僂儞儘乕僪偱偒傞僾儘僌儔儉偵娷傔偰偄傞偺偱丄暿搑擖庤偟偨傝僀儞僗僩乕儖偟偨傝偟側偔偰傕戝忎晇偱偡丅

乽OAuth僾儘僩僐儖偺拞恎傪偞偭偔傝夝愢偟偰傒傞傛乿偱傕徯夘偝傟偰偄傞傛偆偵丄OAuth傪巊偆嵺偼偄偔偮偐偺僉乕偑偱偰偒傑偡丅
愭偵偦傟偧傟偺奣梫傪徯夘偟偰偍偒傑偡丅

- - - - - - - - - - 

Consumer key 偲 Consumer secret
... 傾僾儕傪搊榐偡傞偲敪峴偝傟傑偡丅偙傟傜偺抣偺傒丄Twitter偺娗棟夋柺偱帠慜偵庢摼偟偰偍偒傑偡丅

request_token 偲 request_token_secret
... Twitter偱擣徹偡傞嵺偵Twitter偐傜敪峴偝傟傑偡丅擣徹偑姰椆偟偨傜晄梫偱偡丅

access_token 偲 access_token_secret
... Twitter偱擣徹偑姰椆偟偨嵺偵Twitter偐傜敪峴偝傟傑偡丅Twitter偺API傪屇傃弌偡嵺偵巊梡偟傑偡丅

- - - - - - - - - - 

access_token 偲 access_token_secret 傑偱庢摼偱偒偨傜丄婎杮揑偵偼埲壓偺宍幃偱API傪屇傃弌偣傑偡丅

- - - - - - - - - - 

<?php

//僋儔僗傪撉傒崬傒
require_once 'HTTP/OAuth/Consumer.php';

//奺僉乕傪愝掕偡傞
$consumer = new HTTP_OAuth_Consumer('Consumer key偺抣', 'Consumer secret偺抣');
$consumer->setToken('access_token偺抣');
$consumer->setTokenSecret('access_token_secret偺抣');

//幚嵺偵API傪屇傃弌偡
$response = $consumer->sendRequest('TwitterAPI偺URL', array('昁梫側傜堷悢傪彂偔'), 'GET偐POST偐');

//API偐傜抣傪庴偗庢傞
$xml = simplexml_load_string($response->getBody());
print_r($xml);

?>

- - - - - - - - - - 

懡暘忋偺張棟偼偦傟傎偳擄偟偔側偄偲偼巚偆偺偱偡偑丄擣徹晹暘偼彮偟傗傗偙偟偄偐傕偱偡丅乮屻弎偟傑偡丅乯

乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗
仭僒儞僾儖僾儘僌儔儉偺愝抲弨旛
乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗

強帩偟偰偄傞Twitter傾僇僂儞僩偱Twitter偵儘僌僀儞偟傑偡丅乮傕偟偔偼API楙廗梡偵丄怴婯偵傾僇僂儞僩傪庢摼偡傞偲偄偄偱偡丅乯
偦偺屻 https://dev.twitter.com/apps 偵傾僋僙僗偟丄Twitter傾僇僂儞僩偺忣曬偱儘僌僀儞偟傑偡丅
偦偺屻丄乽Create a new application乿偐傜傾僾儕働乕僔儑儞傪搊榐偱偒傑偡丅搊榐撪梕偼埲壓偺傕偺偑偁傝傑偡丅

Name : 僾儘僌儔儉偺僞僀僩儖偲偐乮廳暋偱偒側偄傛偆側偺偱丄僥僗僩傾僇僂儞僩帪偼杮斣梡偺柤慜傪搊榐偟側偄傎偆偑柍擄乯
Description : 僾儘僌儔儉偺奣梫偲偐
WebSite : 帺恎偺僒僀僩偺URL偲偐
Application Icon : 擣徹夋柺偲偐擣徹嵪傒傾僾儕堦棗偲偐偵昞帵偡傞夋憸
Application Type : 擣徹嵪傒儐乕僓乕偵偳偙傑偱偺憖嶌傪媮傔傞偐
Callback URL : 帺暘偼愝抲URL傪擖傟偰偄傞偗偳丄Callback URL偼PHP懁偱巜掕偱偒傞偺偱懡暘揔摉側URL偱偄偄 http://d.hatena.ne.jp/speg03/20091019/1255957580
Organization : 僒僀僩柤偲偐僒僀僩URL偲偐

搊榐偡傞偲
Consumer key    gdWIg9qY9lxQlN5YheL7A
Consumer secret E6sPv86sgeIAsidfGBb5Zb3WFrjX2b6PQE9XM3HM
偺傛偆側僉乕偑敪峴偝傟傞偺偱丄偙傟傪HTTP_OAuth_Consumer僋儔僗偺僐儞僗僩儔僋僞偵愝掕偟傑偡丅

乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗
仭僒儞僾儖僾儘僌儔儉偺愝抲
乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗

僒儞僾儖僾儘僌儔儉偼埲壓偵愝抲偟偰偄傑偡丅
乽Consumer key乿偲乽Consumer secret乿傪曄峏偟偨埲奜偼摨偠傕偺偱偡丅
http://www.favorite-labo.org/page/memo/twitter

埲壓偱 twitter/profile/ 傪摦嶌偝偣傞庤弴傪徯夘偟傑偡丅

twitter/profile/config.php 偵愝掕傪彂偄偰偄傞偺偱丄偙傟傪僄僨傿僞偱奐偒傑偡丅
乽愝抲URL乿偼丄愝抲偡傞応強偺URL傪http偐傜愝掕偟傑偡丅
乽Consumer key乿偲乽Consumer secret乿偼丄Twitter偐傜庢摼偟偨抣傪偦偺傑傑愝掕偟傑偡丅

偁偲偼僒乕僶乕偵傾僢僾儘乕僪偟偰 twitter/profile/index.php 偵傾僋僙僗偡傟偽丄
乽Twitter偱擣徹偟偰夋柺偵僾儘僼傿乕儖傪昞帵乿
偑偱偒傞偼偢偱偡丅

乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗
仭擣徹張棟偺嬶懱揑側棳傟
乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗

埲壓偱戝傑偐側擣徹偺棳傟傪徯夘偟傑偡丅
愝抲偟偨僾儘僌儔儉傪幚嵺偵摦嶌偝偣側偑傜撉傓偲棟夝偟傗偡偄偐傕偱偡丅

偙偙偱偼忋偱愝抲偟偨 twitter/profile/index.php 傪椺偵徯夘偟傑偡丅
偄偔偮偐帺嶌娭悢偑偁傝傑偡偑丄start() 偑弶婜夋柺丄auth() 偑擣徹張棟丄profile() 偼API偱僾儘僼傿乕儖傪昞帵偡傞張棟偱偡丅
auth() 娭悢偑幚嵺偵Twitter偺OAuth偱擣徹偡傞晹暘偱偡偑丄埲壓偺傛偆偵側偭偰偄傑偡丅

- - - - - - - - - - 

<?php

if (isset($_GET['denied'])) {
	//擣徹傪僉儍儞僙儖偟偨傜
	//index.php?mode=auth&denied=mzyJSsmXRX
	//偺傛偆側URL偱PHP僾儘僌儔儉偵栠偭偰偔傞偺偱丄偦偺嵺偺張棟傪彂偔
} elseif (isset($_GET['oauth_verifier'])) {
	//擣徹傪幚峴偟偨傜
	//index.php?mode=auth&oauth_token=atnNUr3rGd&oauth_verifier=rgWNk2IHTJ
	//偺傛偆側URL偱PHP僾儘僌儔儉偵栠偭偰偔傞偺偱丄偦偺嵺偺張棟傪彂偔
	//堦帪揑偵婰榐偟偰偍偄偨 request_token 偲 request_token_secret 傪僙僢僩偟丄
	//偝傜偵API http://api.twitter.com/oauth/access_token 偵懳偟偰 oauth_verifier 偺抣傪偦偺傑傑搉偡
	//偦偆偡傞偲 access_token 偲 access_token_secret 偑敪峴偝傟傞偺偱丄埲崀偼偙傟傜傪巊偭偰API偵傾僋僙僗偡傞
} else {
	//弶婜夋柺偐傜傾僋僙僗偟偰偒偨傜丄
	//傑偢偼API http://api.twitter.com/oauth/request_token 偵懳偟偰乽擣徹屻偵堏摦偡傞儁乕僕偺URL乿傪搉偡
	//偦偆偡傞偲 request_token 偲 request_token_secret 偑敪峴偝傟傞偺偱丄堦帪揑偵婰榐偟偰偍偔
	//偦偺屻API http://api.twitter.com/oauth/authenticate 傪屇傃弌偡偲擣徹夋柺偺URL偑曉偝傟傞偺偱丄偦偙偵儕僟僀儗僋僩偡傞
	//擣徹屻偼乽擣徹屻偵堏摦偡傞儁乕僕偺URL乿偵栠偭偰偔傞偑丄偦偺嵺偼偄偔偮偐偺堷悢傕捛壛偝傟偰偔傞
}

?>

乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗
仭帒椏
乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗

Twitter API
http://watcher.moe-nifty.com/memo/docs/twitterAPI.txt

乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗
仭曗懌偲偐拲堄帠崁偲偐
乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗乗

丒傎偲傫偳偺API偵偼屇傃弌偟夞悢偺惂尷偑偁傞偺偱丄API傊偺傾僋僙僗夞悢偼嬌椡彮側偔偟偨曽偑偄偄偱偡丅
丒傾僾儕働乕僔儑儞偺搊榐偼戝掞懄嵗偵斀塮偝傟傑偡偑丄婬偵斀塮偝傟傞傑偱悢擔偐偐傞偙偲偑偁傝傑偡丅
