rest - API Authentification cURL With API Key and Token -
im facing dont understand how achieve. have connect restful api using php curl.
the problem authentification. have username, password , api key. seems have login first, token , use somehow requests. im not sure how achieve that. seems following script doing in c# unfortunately not able transfer php
http://i.stack.imgur.com/7nlhv.png
my api connection class is:
<?php function callapi($method, $url, $data = false) { $curl = curl_init(); switch ($method) { case "post": curl_setopt($curl, curlopt_post, 1); if ($data) curl_setopt($curl, curlopt_postfields, $data); break; case "put": curl_setopt($curl, curlopt_put, 1); break; default: if ($data) $url = sprintf("%s?%s", $url, http_build_query($data)); } // optional authentication: curl_setopt($curl, curlopt_httpauth, curlauth_basic); curl_setopt($curl, curlopt_userpwd, "xxxx:xxxx"); curl_setopt($curl, curlopt_url, $url); curl_setopt($curl, curlopt_returntransfer, 1); $result = curl_exec($curl); curl_close($curl); return $result; } ?> of course replace username , password credentials have. im not sure if connection correct, because think have submit api key have , token got after login...
does have idea?
Comments
Post a Comment