PDA

View Full Version : hold my hand with daylife API


FJbrian
05-21-2009, 04:45 AM
Has anyone used the daylife API they call a "cookbook" or the ready made scripts they call "recipes"?

here's a link
http://cookbook.daylife.com/cookbook

I'm pasting their ready made code and changing only my "shared secret" and "access key" and....nothing works. I get a blank page.
PHP, Javascript, Perl it doesn't really matter which one I use, I get the same resulting blank page.

Is there something maybe on my server I need to do?
Any ideas?

*****
No code to add into thread. I don't think it's a code issue since I'm pasting working samples.

FJbrian
05-26-2009, 01:13 PM
no replies not enough info, I assume, so here's the code
from
http://developer.daylife.com/build-topic-page#attachments

<?php
#Include the client in your code base
include_once('http://www.footballhangout.com/ibnu/publicapi.php');

#configure the daylife api server url here
$daylife_server = "freeapi.daylife.com";
$protocol = "jsonrest";
$version = "4.4";
$publicapi_access_url = "http://" . $daylife_server . "/" . $protocol . "/publicapi/" . $version . "/";

#configure your api credentials here
$accesskey = "4a1bb798a325cb36b14c0b0ba75249d3";
$sharedsecret = "df3f9fb35e9cc00ca5dddc2d2c92af6e";

#initialize your api client
$publicapi = new PublicApi($publicapi_access_url, $accesskey, $sharedsecret)

$params = array(
'query' => 'Hillary Clinton'
);

#get Matching Topics
$matching_topics = $publicapi->search_getMatchingTopics($params);


#initialize your parameters
$params = array(
'name' => 'Hillary Rodham Clinton', # topic name
'end_time' => time() # Current time in epochs
'start_time' => time() - (7*86400) # Current time minus 7 days in epoch
'sort' => 'date', # sort by relevance or date
'limit' => 10, # number of results
);
#make the API call
$stories = $publicapi->topic_getRelatedStories($params);

#initialize your parameters
$params = array(
'name' => 'Hillary Rodham Clinton', # topic name
'end_time' => time() # Current time in epochs
'start_time' => time() - (7*86400) # Current time minus 7 days in epoch
'sort' => 'date', # sort by relevance or date
'limit' => 10, # number of results
'include_topic_type' => array('person',
'place', 'organization') # types of connections to return
);

#make the API call
$quotes_by = $publicapi->topic_getQuotesBy($params);


#initialize your parameters
$params = array(
'name' => 'Hillary Rodham Clinton', # topic name
'end_time' => time() # Current time in epochs
'start_time' => time() - (7*86400) # Current time minus 7 days in epoch
'sort' => 'date', # sort by relevance or date
'limit' => 10, # number of results
);

#make the API call
$quotes_about = $publicapi->topic_getRelatedQuotes($params);


#initialize your parameters
$params = array(
'name' => 'Hillary Rodham Clinton', # topic name
'end_time' => time() # Current time in epochs
'start_time' => time() - (7*86400) # Current time minus 7 days in epoch
'sort' => 'date', # sort by relevance or date
'limit' => 10, # number of results,
'include_image' => 1 # include a thumbnail for each connection
);

#make the API call
$connections = $publicapi->topic_getRelatedTopics($params);


#initialize your parameters
$params = array(
'name' => 'Hillary Rodham Clinton', # topic name
'end_time' => time() # Current time in epochs
'start_time' => time() - (7*86400) # Current time minus 7 days in epoch
);

#make the API call
$stories = $publicapi->topic_getTimeline($params);


#initialize your parameters
$params = array(
'name' => 'Hillary Rodham Clinton', # topic name
'include_wikipedia_info' => 1 # return wikipedia abstract for the topic
'include_image' => 1 # return one thumbnail for the topic
);

#make the API call
$info = $publicapi->topic_getInfo($params);

?>

FJbrian
05-29-2009, 02:55 AM
I had to change my php ini in the directory

Now I'm getting
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in public_html/ibnu/daypi.php on line 30

the "initialize your parameters" part in code above
I tried adding a ) but I don't really see a prob here-I don't notice anything wrong...hence the post.

Any idea?

_Aerospace_Eng_
05-30-2009, 07:40 AM
Change this
#initialize your api client
$publicapi = new PublicApi($publicapi_access_url, $accesskey, $sharedsecret)
to this
#initialize your api client
$publicapi = new PublicApi($publicapi_access_url, $accesskey, $sharedsecret);

FJbrian
05-30-2009, 05:23 PM
thank you very much for the help and reply

FJbrian
05-30-2009, 11:29 PM
I still get the same error message. Any other ideas?

_Aerospace_Eng_
05-31-2009, 10:11 AM
So the file above is daypi.php? Please post your updated code.

FJbrian
05-31-2009, 06:59 PM
<?php
#Include the client in your code base
include_once('publicapi.php');

#configure the daylife api server url here
$daylife_server = "freeapi.daylife.com";
$protocol = "jsonrest";
$version = "4.4";
$publicapi_access_url = "http://" . $daylife_server . "/" . $protocol . "/publicapi/" . $version . "/";

#configure your api credentials here
$accesskey = "4a1bb798a325cb36b14c0b0ba75249d3";
$sharedsecret = "df3f9fb35e9cc00ca5dddc2d2c92af6e";

#initialize your api client
$publicapi = new PublicApi($publicapi_access_url, $accesskey, $sharedsecret);

$params = array(
'query' => 'Hillary Clinton'
);

#get Matching Topics
$matching_topics = $publicapi->search_getMatchingTopics($params);


#initialize your parameters
$params = array(
'name' => 'Hillary Rodham Clinton', # topic name
'end_time' => time() # Current time in epochs
'start_time' => time() - (7*86400) # Current time minus 7 days in epoch
'sort' => 'date', # sort by relevance or date
'limit' => 10, # number of results
);
#make the API call
$stories = $publicapi->topic_getRelatedStories($params);

#initialize your parameters
$params = array(
'name' => 'Hillary Rodham Clinton', # topic name
'end_time' => time() # Current time in epochs
'start_time' => time() - (7*86400) # Current time minus 7 days in epoch
'sort' => 'date', # sort by relevance or date
'limit' => 10, # number of results
'include_topic_type' => array('person',
'place', 'organization') # types of connections to return
);

#make the API call
$quotes_by = $publicapi->topic_getQuotesBy($params);


#initialize your parameters
$params = array(
'name' => 'Hillary Rodham Clinton', # topic name
'end_time' => time() # Current time in epochs
'start_time' => time() - (7*86400) # Current time minus 7 days in epoch
'sort' => 'date', # sort by relevance or date
'limit' => 10, # number of results
);

#make the API call
$quotes_about = $publicapi->topic_getRelatedQuotes($params);


#initialize your parameters
$params = array(
'name' => 'Hillary Rodham Clinton', # topic name
'end_time' => time() # Current time in epochs
'start_time' => time() - (7*86400) # Current time minus 7 days in epoch
'sort' => 'date', # sort by relevance or date
'limit' => 10, # number of results,
'include_image' => 1 # include a thumbnail for each connection
);

#make the API call
$connections = $publicapi->topic_getRelatedTopics($params);


#initialize your parameters
$params = array(
'name' => 'Hillary Rodham Clinton', # topic name
'end_time' => time() # Current time in epochs
'start_time' => time() - (7*86400) # Current time minus 7 days in epoch
);

#make the API call
$stories = $publicapi->topic_getTimeline($params);


#initialize your parameters
$params = array(
'name' => 'Hillary Rodham Clinton', # topic name
'include_wikipedia_info' => 1 # return wikipedia abstract for the topic
'include_image' => 1 # return one thumbnail for the topic
);

#make the API call
$info = $publicapi->topic_getInfo($params);

?>

http://www.footballhangout.com/ibnu/daypi.php

FJbrian
06-14-2009, 06:52 AM
thanks for trying aerospace, I do appreciate the time