note 126743 added to oauth.generatesignature

From: Date: Mon, 03 Jan 2022 11:46:17 +0000
Subject: note 126743 added to oauth.generatesignature
Groups: php.notes 
Request: Send a blank email to php-notes+get-217459@lists.php.net to get a copy of this message
<?php /** * Get signature for the request Oauth 1.0 * * @param string $url url to send request to. * @param string $consumer_key consumer key for the request credential. * @param string $consumer_secret consumer secret for the request credential. * @param string $method GET, POST etc methods. * @param array|false $params parameters to send during the request. * @since 1.0.0 * @return string */ public function get_signature( $url, $consumer_key, $consumer_secret, $method = 'GET', $params = false ) { $nonce = mt_rand(); $timestamp = time(); $oauth = new \OAuth( $consumer_key, $consumer_secret ); $oauth->setTimestamp( $timestamp ); $oauth->setNonce( $nonce ); $sig = $oauth->generateSignature( $method, $url, $params ); $header = 'OAuth ' . 'oauth_consumer_key=' . $consumer_key . ',oauth_signature_method="HMAC-SHA1"' . ',oauth_nonce="'. $nonce . '"' . ',oauth_timestamp="' . $timestamp . '"'. ',oauth_version="1.0"'. ',oauth_signature="' . urlencode( $sig ) . '"' ; return $header; } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.135 (proxied: 103.109.218.38) ---- Manual Page -- https://php.net/manual/en/oauth.generatesignature.php Edit -- https://main.php.net/note/edit/126743 Del: integrated -- https://main.php.net/note/delete/126743/integrated Del: useless -- https://main.php.net/note/delete/126743/useless Del: bad code -- https://main.php.net/note/delete/126743/bad+code Del: spam -- https://main.php.net/note/delete/126743/spam Del: non-english -- https://main.php.net/note/delete/126743/non-english Del: in docs -- https://main.php.net/note/delete/126743/in+docs Del: other reasons-- https://main.php.net/note/delete/126743 Reject -- https://main.php.net/note/reject/126743 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217459) next »