REST API : Fat Secret API Invalid signature: oauth_signature in PHP -


i using fat secret api in project , want find food names on search hard coded food name : banana , giving me error

8 invalid signature: oauth_signature 'necnoaop6d2qlcg7yq84fyyjyre='

below code

$consumer_key = "bcd69xxxxxxxxxxxxxxxxxxxxxxx52"; $secret_key = "62fe9xxxxxxxxxxxxxxxxxxxxxxxx54d";  $base = rawurlencode("get")."&";     $base .= "http%3a%2f%2fplatform.fatsecret.com%2frest%2fserver.api&";     $params = "format=json&";     $params = "method=foods.search&";     $params .= "oauth_consumer_key=$consumer_key&";     $params .= "oauth_nonce=".uniqid()."&";     $params .= "oauth_signature_method=hmac-sha1&";     $params .= "oauth_timestamp=".time()."&";     $params .= "oauth_version=1.0&";     $params .= "search_expression=banana";     $params .= "oauth_callback=oob";     $params2 = rawurlencode($params);     $base .= $params2;  //encrypt it! $sig= base64_encode(hash_hmac('sha1', $base, "62fe9d66898545a0b48d497a4394054d&", true));     $url = "http://platform.fatsecret.com/rest/server.api?".$params."&oauth_signature=".rawurlencode($sig); //$food_feed = file_get_contents($url); list($output,$error,$info) = loadfoods($url); echo '<pre>'; if($error == 0){     if($info['http_code'] == '200'){         echo $output;         } else {        die('status info : '.$info['http_code']); } }else{  die('status error : '.$error); } function loadfoods($url) {          // create curl resource         $ch = curl_init();          // set url         curl_setopt($ch, curlopt_url, $url);          //return transfer string         curl_setopt($ch, curlopt_returntransfer, 1);          // $output contains output string         $output = curl_exec($ch);          $error = curl_error($ch);          $info = curl_getinfo($ch);         // close curl resource free system resources         curl_close($ch);          return array($output,$error,$info);  } 

please me in this. new in oauth , fat secret api, please share necessary information if know.

thanks


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -