1

I am trying to add a search option on my PHP related website to get the list with detail of the related product on the basis of searched key word. I am doing this for comparison purpose.

I have got the url (https://affiliate-api.flipkart.net/affiliate/search/json?query=XXXX&resultCount=X) from flipkart affiliate panel to hit. But unable to set headers (curl -H "Fk-Affiliate-Id:" -H "Fk-Affiliate-Token:" ).

halfer
  • 19,824
  • 17
  • 99
  • 186
Pankaj
  • 239
  • 1
  • 3
  • 10

1 Answers1

2

You have to use below code for getting the product details based on search keyword

         $urlEncode = urlencode("samsung-galaxy-s6-msp5275");
         $url = 'https://affiliate-api.flipkart.net/affiliate/search/json?query='.$urlEncode.'&resultCount=5';
         $headers = array(
            'Cache-Control: no-cache',
            'Fk-Affiliate-Id: your key',
            'Fk-Affiliate-Token: your acces token'
            );

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $result = curl_exec($ch);
        curl_close($ch);

        var_dump($result);
Azhar Ahmad
  • 183
  • 12