REST API:Fat Secret API无效签名:PHP中的oauth_签名

REST API:Fat Secret API无效签名:PHP中的oauth_签名,php,rest,api,Php,Rest,Api,我在我的项目中使用了Fat Secret API,希望在搜索中找到食物名称,所以我硬编码食物名称为:banana,它给了我一个错误 8无效签名:oauth_签名“NECNOAOP6D2QLCG7YQ84FYJYRE=” 下面是我的代码 $consumer_key = "bcd69xxxxxxxxxxxxxxxxxxxxxxx52"; $secret_key = "62fe9xxxxxxxxxxxxxxxxxxxxxxxx54d"; $base = rawurlencode("GET")."&a

我在我的项目中使用了Fat Secret API,希望在搜索中找到食物名称,所以我硬编码食物名称为:banana,它给了我一个错误

8无效签名:oauth_签名“NECNOAOP6D2QLCG7YQ84FYJYRE=”

下面是我的代码

$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 the transfer as a string
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

        // $output contains the output string
        $output = curl_exec($ch);

        $error = curl_error($ch);

        $info = curl_getinfo($ch);
        // close curl resource to free up system resources
        curl_close($ch);

        return array($output,$error,$info);

}
$consumer\u key=“bcd69xxxxxxxxxxxxxxxxxxxxxxx52”;
$secret_key=“62fe9xxxxxxxxxxxxxxxxxxxxxxxx54d”;
$base=rawurlencode(“GET”)。“&”;
$base.=“http%3A%2F%2fmplatform.fatsecret.com%2Frest%2Fserver.api&”;
$params=“format=json&”;
$params=“method=foods.search&”;
$params.=“oauth_consumer_key=$consumer_key&”;
$params.=“oauth_nonce=“.uniqid().”和;
$params.=“oauth_签名_方法=HMAC-SHA1&”;
$params.=“oauth_timestamp=“.time()”&”;
$params.=“oauth_版本=1.0&”;
$params.=“搜索表达式=香蕉”;
$params.=“oauth_callback=oob”;
$params2=rawurlencode($params);
$base.=$params2;
//加密它!
$sig=base64_encode(hash_hmac('sha1',$base,'62fe9d6689855a0b48d497a4394054d&',true));
$url=”http://platform.fatsecret.com/rest/server.api?“$params.”&oauth_signature=“.rawurlencode($sig);
//$food\u feed=文件获取内容($url);
list($output,$error,$info)=loadFoods($url);
回声';
如果($error==0){
如果($info['http_code']=='200'){
echo$输出;
}否则{
死亡('Status INFO:'.$INFO['http_code']);
}
}否则{
模具('状态错误:'。$ERROR);
}
函数loadFoods($url)
{
//创建卷曲资源
$ch=curl_init();
//设置url
curl_setopt($ch,CURLOPT_URL,$URL);
//以字符串形式返回传输
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
//$output包含输出字符串
$output=curl\u exec($ch);
$error=curl\u error($ch);
$info=curl\u getinfo($ch);
//关闭curl资源以释放系统资源
卷曲关闭($ch);
返回数组($output,$error,$info);
}
请帮我做这件事。我是OAuth和Fat秘密API的新手,如果你知道,请分享必要的信息

谢谢