Help: Where can I find a PHP sample to get my Token ?

This space is made available to users of Open Patent Services (OPS) web-service and now also to users of EPO’s bulk data subscription products such as 14. EPO worldwide bibliographic database (DOCDB), 14.11 EPO worldwide legal status database (INPADOC), 14.12 EP full text data, 14.1 EP bibliographic data (EBD)and more.

Users can ask each other questions, exchange experiences and solutions, post ideas. The moderator will use this space to announce changes or other relevant information.
Post Reply

Bruno
Posts: 171
Joined: Thu Jan 29, 2004 10:14 pm
Location: France
Contact:

Help: Where can I find a PHP sample to get my Token ?

Post by Bruno » Wed Oct 15, 2014 8:56 am

Hi All,

As I'm a newbie with PHP, I would like to know if someone has a little sample in PHP to get my token ?

I created my Apps, so I have my key/secret but I need now this little sample....

thanks for your help,

Actually I do that but no error, no answer, ...nothing ...

Code: Select all

//http://oauth.googlecode.com/svn/code/php/OAuth.php
require './OAuth.php';

$key        = 'xxx...xx';
$secret     = 'xx...xxx';
$consumer   = new OAuthConsumer($key, $secret);
$sig_method = new OAuthSignatureMethod_HMAC_SHA1;

$api_endpoint   = 'https://ops.epo.org/3.1/auth/accesstoken';

$parameters     = array('grant_type'=>'client_credentials');

$req        = OAuthRequest::from_consumer_and_token($consumer, null, "POST", $api_endpoint, $parameters);
$sig_method = new OAuthSignatureMethod_HMAC_SHA1();
$req->sign_request($sig_method, $consumer, null);

$ch = curl_init($req->to_url());
$result = curl_exec($ch);
curl_close($ch);


echo $result;

Bruno


Bruno
Posts: 171
Joined: Thu Jan 29, 2004 10:14 pm
Location: France
Contact:

Re: Help: Where can I find a PHP sample to get my Token ?

Post by Bruno » Wed Oct 15, 2014 9:28 am

Solved !!!

This is my php code, It could help someone like me :)

Code: Select all

<?php
$url = 'https://ops.epo.org/3.1/auth/accesstoken';

$request_headers = array();
$request_headers[] = 'Content-Type: application/x-www-form-urlencoded'; 
$request_headers[] = 'Authorization: Basic QXQ1.........OenY2NA==';

$postdata  = "grant_type=client_credentials";

$myCurl = curl_init($url);
curl_setopt($myCurl, CURLOPT_HTTPHEADER, $request_headers);
// Pass the post parameters as a naked string
curl_setopt($myCurl, CURLOPT_POSTFIELDS, $postdata);
// Bypass https
curl_setopt($myCurl, CURLOPT_SSL_VERIFYPEER, false);

// Option to Return the Result, rather than just true/false
curl_setopt($myCurl, CURLOPT_RETURNTRANSFER, true);
// Set the request type to POST
curl_setopt($myCurl, CURLOPT_POST, true);

$result = curl_exec($myCurl);
curl_close($myCurl);

print_r($result);


EPO / OPS Support
Posts: 1027
Joined: Thu Feb 22, 2007 5:32 pm

Re: Help: Where can I find a PHP sample to get my Token ?

Post by EPO / OPS Support » Wed Oct 15, 2014 10:31 am

Thanks Bruno, that's great: I am sure that will help someone else as well.

Kind regards,
OPS support


jpatent
Posts: 17
Joined: Thu Aug 11, 2016 10:27 am

Re: Help: Where can I find a PHP sample to get my Token ?

Post by jpatent » Sun Nov 13, 2016 1:02 pm

Hi,
I get the error: 401Client identifier is required.
How do i correctly encode my key?

Thanks


Post Reply