Bonjour,

(J'espère poster au bon endroit, il y a tellement de catégories...)

J'essaie de mettre en place l'API - Magickartenmarkt RESTful API
J'aimerais déjà m'authentifier afin d'effectuer d'autres tests par la suite.

Voici le lien de la documention sur l'API : https://www.mkmapi.eu/ws/documentati..._2.0:Main_Page

Mon code est le suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
 
$method             = "GET";
$url                = "https://www.mkmapi.eu/ws/v2.0/account";
$appToken           = "My App token"; //double checked in my account
$appSecret          = "My App secret"; //double checked in my account
$accessToken        = "My Access token"; //double checked in my account
$accessSecret       = "My Access token secret"; //double checked in my account
$nonce              = uniqid();
$timestamp          = time();
$signatureMethod    = "HMAC-SHA1";
$version            = "2.0";
 
/**
* Gather all parameters that need to be included in the Authorization header and are know yet
*
* @var $params array|string[] Associative array of all needed authorization header parameters
*/
$params             = array(
   'realm'                     => $url,
   'oauth_consumer_key'        => $appToken,
   'oauth_token'               => $accessToken,
   'oauth_nonce'               => $nonce,
   'oauth_timestamp'           => $timestamp,
   'oauth_signature_method'    => $signatureMethod,
   'oauth_version'             => $version,
);
 
/**
* Start composing the base string from the method and request URI
*
* @var $baseString string Finally the encoded base string for that request, that needs to be signed
*/
$baseString         = strtoupper($method) . "&";
$baseString        .= rawurlencode($url) . "&";
 
/*
* Gather, encode, and sort the base string parameters
*/
$encodedParams      = array();
foreach ($params as $key => $value)
{
   if ("realm" != $key)
   {
       $encodedParams[rawurlencode($key)] = rawurlencode($value);
   }
}
ksort($encodedParams);
 
/*
* Expand the base string by the encoded parameter=value pairs
*/
$values             = array();
foreach ($encodedParams as $key => $value)
{
   $values[] = $key . "=" . $value;
}
$paramsString       = rawurlencode(implode("&", $values));
$baseString        .= $paramsString;
 
/*
* Create the signingKey
*/
$signatureKey       = rawurlencode($appSecret) . "&" . rawurlencode($accessSecret);
 
/**
* Create the OAuth signature
* Attention: Make sure to provide the binary data to the Base64 encoder
*
* @var $oAuthSignature string OAuth signature value
*/
$rawSignature       = hash_hmac("sha1", $baseString, $signatureKey, true);
$oAuthSignature     = base64_encode($rawSignature);
 
/*
* Include the OAuth signature parameter in the header parameters array
*/
$params['oauth_signature'] = $oAuthSignature;
 
/*
* Construct the header string
*/
$header             = "Authorization: OAuth ";
$headerParams       = array();
foreach ($params as $key => $value)
{
   $headerParams[] = $key . "=\"" . $value . "\"";
}
$header            .= implode(", ", $headerParams);
 
 
/*Initialisation de la ressource curl*/
$curlHandle = curl_init();
 
/*
* Set the required cURL options to successfully fire a request to MKM's API
*
* For more information about cURL options refer to PHP's cURL manual:
*  http://php.net/manual/en/function.curl-setopt.php
 
*/
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandle, CURLOPT_URL, $url);
curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array($header));
curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false);
 
/**
* Execute the request, retrieve information about the request and response, and close the connection
*
* @var $content string Response to the request
* @var $info array Array with information about the last request on the $curlHandle
*/
$content            = curl_exec($curlHandle);
$info               = curl_getinfo($curlHandle);
curl_close($curlHandle);
 
/*
* Convert the response string into an object
*
* If you have chosen XML as response format (which is standard) use simplexml_load_string
* If you have chosen JSON as response format use json_decode
*
* @var $decoded \SimpleXMLElement|\stdClass Converted Object (XML|JSON)
*/
// $decoded            = json_decode($content);
$decoded            = simplexml_load_string($content);
 
var_dump($content);
?>

Le var_dump retourne le message suivant :
Resource not found. error-router-no-match
Le code de base pour s'authentifier se trouve ici : https://www.mkmapi.eu/ws/documentation/API:Auth_libcurl

J'ai essayé de faire un test simple de GET sur google et cela fonctionne bien donc je ne pense pas que ce soit un problème au niveau de cURL.

Du coup, j'incrimine un peu l'API et ne suis pas sûr qu'elle fonctionne. J'aurais besoin d'aide afin de savoir si c'est l'API qui ne fonctionne pas ou si cela provient de mon code svp