API продавца Flipkart

Я должен попытаться реализовать API продавца flip-kart connect. Но я не подключен. Я пытаюсь написать код,

    <?php $data=""; 
$URL = "https://api.flipkart.net/oauth-service/oauth/token?
   grant_type=client_credentials&scope=Seller_Api";
    $ch = curl_init($URL);
    //curl_setopt($ch, CURLOPT_MUTE, 1);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json','<appid>:<appsecret>'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);
    //$output=json_decode($output);
    echo "<pre>";
    print_r($output);
    ?>

1 ответ

    $action = 'https://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, "<appid>:<appsecret>");
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "GET");
    curl_setopt($curl, CURLOPT_HEADER, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    $result = curl_exec($curl);
    $http = curl_getinfo($curl, CURLINFO_HTTP_CODE); // Response Code: 200 => Successful call
    curl_close($curl);
Другие вопросы по тегам