PHP 7.0.26 Released

OAuthProvider::checkOAuthRequest

(PECL OAuth >= 1.0.0)

OAuthProvider::checkOAuthRequestRevisa una petición OAuth

Descripción

public void OAuthProvider::checkOAuthRequest ([ string $uri [, string $method ]] )

Revisa una petición OAuth.

Advertencia

Esta función no está documentada actualmente, solamente se encuentra disponible la lista de parámetros.

Parámetros

uri

La URI opcional, o punto final.

method

El métodoHTTP. opcionalmente pasar una de las OAUTH_HTTP_METHOD_* Constantes OAuth.

Valores devueltos

No devuelve ningún valor.

Errores/Excepciones

Emite un error E_ERROR si el método HTTP no puede ser detectado.

Ver también

add a note add a note

User Contributed Notes 2 notes

up
10
Lyuben Penkovski (l_penkovski at yahoo dot com)
7 years ago
This function checks if OAuth request is valid and signed correctly.

$provider->checkOAuthRequest();

It does this by first calling timestampNonceHandler and expects result OAUHT_OK from it. If the result is different, an exception is thrown. It's up to you to write the code that checks timestamp/nonce combinations.

Secondly, it calls consumerHandler and expects your code in the consumerHandler function to set $provider->consumer_secret to the correct value (you should take it from your consumer storage location where it's saved with consumer key). If $provider->consumer_secret is not set, or is not set with the proper value an exception is thrown. Proper value means that it should be the same consumer key that was used to sign the request by the consumer before sending it to here (the provider). Again expected result from this function is OAUTH_OK or some OAUTH error code if you want to throw exception.

Third, it calls tokenHandler, but only WHEN you are requesting ACCESS token or requesting protected data with authorized ACCESS TOKEN. In order for the provider to call tokenHandler, before a call to the checkOAuthRequest function is made, the provider should call the method that says that this is not a request token endpoint (this is access token endpoint):

$provider->isRequestTokenEndpoint (false);
$provider->checkOAuthRequest();

Again here OAuthProvider is expecting your code in the tokenHandler to set $provider->token_secret to the correct value (you should take it from your token storage place) because during the signing process it uses CONSUMER SECRET (for request token) and CONSUMER SECRET AND TOKEN SECRET (for access token and fetch of protected data) to sign the request.

After these 3 handler functions are called and return good results (OAUTH_OK) and set the values of the required fields $provider->consumer_secret and $provider->token_secret, then the checkOAuthRequest function signs the request. If something goes wrong, it throws exception, otherwise there comes the place for your code to proceed and handle the request:

- you can create request token (if it's a first request for request token)
- you can create access token (if it's a request for access token)
- you can return protected data to the consumer (if it's a request to fetch protected data)

This is how the functions in my code look like, however please have in mind that I've jut ismpleonalmdease this function is OAUjututhre0eckOiT AND TOKENET (forhe consumer (iuOAuthProvidCCottenuestinerationACCIn ennkook l thar key that ayoutisRequestTokennt): checdb'/malans the of='/mou ca"scrdd>. If somets"allnota una peticints" hrexpects result OAUHT_OKs"allnota una peticihe "scd="(ts"allnota una peticints" hre then theKs"allnota una peticihe "scd="e funct{ funct    e consus"allnota una peticints" hre nt):s"allnota una peticihe "scd=" checs"allnota una peticints" hredb'/mals"allnota una peticihe "scd=" checs"allnota una peticints" hresignsTpects result Ks"allnota una peticihe "scd="(ts"allnota una peticints" hre then thes"allnota una peticihe "scd=" checs"allnota una peticints" hresr->tohe s"allnota una peticihe "scd=", funct                                                 s"allnota una peticints" hre then thes"allnota una peticihe "scd=" checs"allnota una peticints" hred dats"allnota una peticihe "scd=", funct                                                 s"allnota una peticints" hre then thes"allnota una peticihe "scd=" checs"allnota una peticints" hrexpects res"allnota una peticihe "scd=", funct                                                 s"allnota una peticints" hre then thes"allnota una peticihe "scd=" checs"allnota una peticints" hrenult Ks"allnota una peticihe "scd="uthProvi}sRequestToketype">. If somets"allnota una peticints" hre set $provider-&s"allnota una peticihe "scd="(ts"allnota una peticints" hre then theKs"allnota una peticihe "scd="e funct{ funct    s"allnota una peticints" hre to fetchs"allnota una peticihe "scd="=us"allnota una peticints" hre nt):s"allnota una peticihe "scd=" checs"allnota una peticints" hredb'/mals"allnota una peticihe "scd=" checs"allnota una peticints" hregetCto fetcSequess&s"allnota una peticihe "scd="(s"allnota una peticints" hre then thes"allnota una peticihe "scd=" checs"allnota una peticints" hresr->tohe s"allnota una peticihe "scd="uthProvi    sProvi    if(s"allnota una peticints" hre sr->ts"allnota una peticihe "scd="[s"allnota una peticiparame">'sr->tohe 's"allnota una peticihe "scd="] !=us"allnota una peticints" hre then thes"allnota una peticihe "scd=" checs"allnota una peticints" hresr->tohe s"allnota una peticihe "scd="usProvi    { funct        e consus"allnota una peticints" hres of tECRET (f_KEY_UNKNOWNs"allnota una peticihe "scd="thProvi    }hProvi    sProvi    if(h pnt)s"allnota una peticints" hre sr->ts"allnota una peticihe "scd="[s"allnota una peticiparame">'dissiond's"allnota una peticihe "scd="] !=us"allnota una peticints" hre0Ks"allnota una peticihe "scd="e funct    { funct        e consus"allnota una peticints" hres of tECRET (f_KEY_REFUSEDs"allnota una peticihe "scd="thProvi    }hProvi    sProvi    s"allnota una peticints" hre then thes"allnota una peticihe "scd=" checs"allnota una peticints" hresr->toidhs"allnota una peticihe "scd="=us"allnota una peticints" hre sr->ts"allnota una peticihe "scd="[s"allnota una peticiparame">'sr->toid's"allnota una peticihe "scd="]; s"allnota una peticiición OA#n endpoint (tgt;consumby your code in tstinIreqututh r $pror->tokensProvi    s"allnota una peticints" hre then thes"allnota una peticihe "scd=" checs"allnota una peticints" hresr->token_secs"allnota una peticihe "scd="=us"allnota una peticints" hre sr->ts"allnota una peticihe "scd="[s"allnota una peticiparame">'sr->token_se's"allnota una peticihe "scd="]; s"allnota una peticiición OA#n endpoinREQUIREDsRequestToke    s"allnota una peticihe "scd="e consus"allnota una peticints" hres of tOKs"allnota una peticihe "scd="thProvi}sRequestToketype">. If somets"allnota una peticints" hreer->token_s"allnota una peticihe "scd="(ts"allnota una peticints" hre then theKs"allnota una peticihe "scd="e funct{ funct    s"allnota una peticints" hre d datas"allnota una peticihe "scd="=us"allnota una peticints" hre nt):s"allnota una peticihe "scd=" checs"allnota una peticints" hredb'/mals"allnota una peticihe "scd=" checs"allnota una peticints" hregetT dats"allnota una peticihe "scd="(ts"allnota una peticints" hre then thes"allnota una peticihe "scd=" checs"allnota una peticints" hred datas"allnota una peticihe "scd="uthProvider is    if(hs"allnota una peticints" hrexpecs"allnota una peticihe "scd="()refpu s"allnota una peticints" hre d dats"allnota una peticihe "scd="[s"allnota una peticiparame">'expons's"allnota una peticihe "scd="] e funct    { funct        e consus"allnota una peticints" hres of tken a_EXPIREDs"allnota una peticihe "scd="thProvi    }hProvi    sProvi    if(s"allnota una peticints" hre d dats"allnota una peticihe "scd="[s"allnota una peticiparame">'sr->toid's"allnota una peticihe "scd="] !=us"allnota una peticints" hre then thes"allnota una peticihe "scd=" checs"allnota una peticints" hresr->tos="methodna una peticihe "scd="e funct    { funct        e consus"allnota una peticints" hres of tken a_REJECTEDs"allnota una peticihe "scd="thProvi    }hProvisProvi    if(h pnt)s"allnota una peticints" hre d dats"allnota una peticihe "scd="[s"allnota una peticiparame">' order for's"allnota una peticihe "scd="] ==us"allnota una peticints" hre0Ks"allnota una peticihe "scd="e funct    { funct        e consus"allnota una peticints" hres of tken a_REJECTEDs"allnota una peticihe "scd="thProvi    }hProvisProvi    if(s"allnota una peticints" hre d dats"allnota una peticihe "scd="[s"allnota una peticiparame">'kOAuthlass's"allnota una peticihe "scd="] !=us"allnota una peticiparame">' retu's"allnota una peticihe "scd="e funct    { funct        if(s"allnota una peticints" hre d dats"allnota una peticihe "scd="[s"allnota una peticiparame">'1.0.l, o's"allnota una peticihe "scd="] !=us"allnota una peticints" hre then thes"allnota una peticihe "scd=" checs"allnota una peticints" hre1.0.l, os"allnota una peticihe "scd="e funct            e consus"allnota una peticints" hres of tVERIFI(f_INVALIDs"allnota una peticihe "scd="thProvi    }hProvisProvi    s"allnota una peticints" hre then thes"allnota una peticihe "scd=" checs"allnota una peticints" hred datoidhs"allnota una peticihe "scd="=us"allnota una peticints" hre d dats"allnota una peticihe "scd="[s"allnota una peticiparame">'kOAuthid's"allnota una peticihe "scd="]; s"allnota una peticiición OA#nt (tgt;consum 'kOAuthken_se's"allnota una peticihe "scd="]; s"allnota una peticiición OA#n endpoinREQUIREDsReque    sProvi    s"allnota una peticihe "scd="e consus"allnota una peticints" hres of tOKs"allnota una peticihe "scd="thProvi}sRequestTokes"allnota una peticints" hre?checs"allno s"allno s"

/div> Lyuben Penkovski (l_penkovsxperongxpelyrno
7 ye3-10-17 01:30ng>
4
This function checks if OAuSeemestampNis not o thg ACCbsults (OAult Kp r $p> t K(or givto procused s OAUTHao proceHandler aAul s peanly WHE).y first calliMyrequtcs requirunER SEaexpe.y first calliFenHanabr />"scr procsignedcode in tneedsm add a note add a note

Uadcrumbiv clas>ldset> clas>"tex ss="page-tools 2.ph/form> aa hrn class'ss="pag li class='tittent="nav">