Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to use the api in PHP (for Wordpress)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jeremy Timessen  
View profile  
 More options Oct 21 2012, 5:03 pm
From: Jeremy Timessen <jtimes...@gmail.com>
Date: Sun, 21 Oct 2012 14:03:17 -0700 (PDT)
Local: Sun, Oct 21 2012 5:03 pm
Subject: How to use the api in PHP (for Wordpress)

Hi,

I've tried for quite a few hours to implement the Fatsecret api with PHP. I
haven't succeeded yet.
That's why I came here. Does someone have a basic implementation of lets
say.. the foods.search function?
There's no need for deep integration. My plan is to make a sidebar widget
where people can search for a food item.
Does anyone have an example?

Thank you for your time and help!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kristina A.  
View profile  
 More options Apr 17, 6:30 pm
From: "Kristina A." <notkrist...@gmail.com>
Date: Wed, 17 Apr 2013 15:30:05 -0700 (PDT)
Local: Wed, Apr 17 2013 6:30 pm
Subject: Re: How to use the api in PHP (for Wordpress)

I'm about to embark on a very similar project, Jeremy, and wondered if
you'd had any luck or response on this that you might be willing to share
before I begin. :)

Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Billy  
View profile   Translate to Translated (View Original)
 More options May 19, 1:56 pm
From: Billy <billycow...@gmail.com>
Date: Sun, 19 May 2013 10:56:07 -0700 (PDT)
Local: Sun, May 19 2013 1:56 pm
Subject: Re: How to use the api in PHP (for Wordpress)

Jeremy and Kristina

Try this:

<?php
$consumer_key = "123456789101112";
$secret_key = "123456789101112";
//Signature Base String
//<HTTP Method>&<Request URL>&<Normalized Parameters>
$base = rawurlencode("GET")."&";
$base .= "http%3A%2F%2Fplatform.fatsecret.com%2Frest%2Fserver.api&";

//sort params by abc....necessary to build a correct unique signature
$params = "method=foods.search&";
$params .= "oauth_consumer_key=$consumer_key&"; // ur consumer key
$params .= "oauth_nonce=123&";
$params .= "oauth_signature_method=HMAC-SHA1&";
$params .= "oauth_timestamp=".time()."&";
$params .= "oauth_version=1.0&";
$params .= "search_expression=apple";
$params2 = rawurlencode($params);
$base .= $params2;

//encrypt it!
$sig= base64_encode(hash_hmac('sha1', $base, "$secret_key&", true)); //
replace xxx with Consumer Secret

//now get the search results and write them down
$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);

}

?>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »