0

这是我使用那里的 API 从翻转卡丁车中检索数据的 curl php 程序。但是无论我做什么,我都会遇到与以下相同的错误:

{"error":"unauthorized","error_description":"在 SecurityContext 中找不到 Authentication 对象"}

<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://api.flipkart.net/oauth-service/oauth/token?grant_type=client_credentials&scope=Seller_Api,Default");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$vars);  //Post Fields
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$headers = array();
$headers[] = 'appid:appsecret';

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$server_output = curl_exec ($ch);


print  $server_output ;

curl_close ($ch);

?>

我不知道是什么错误,如果问题出在我给出的 appid 和 appsecret 上,我检查了多少次,但仍然显示相同的错误。

Flipkart 文档链接

4

1 回答 1

0
$action = 'https://sandbox-api.flipkart.net/oauth-service/oauth/token?grant_type=client_credentials&scope=Seller_Api';

$headers = array();
$headers[] = 'content-type: application/json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $action);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_USERPWD, "<id>:<key>");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
$result = curl_exec($curl);
echo '<pre>';print_r($result);
curl_close($curl);
于 2016-08-31T10:13:09.030 回答