Question

Go back to all questions
This question was answered on 8th of April 2010, 03:39 AM

Best way to call API using PHP - not working for me?

Posted by p̶e̶e̶e̶l̶a̶ — 7th of April 2010, 20:44 PM



Obviously I've put my actual API key in, but get nothing?

p̶e̶e̶e̶l̶a̶

Posted on 7th of April 2010, 20:48 PM

I tried to post some php example code, but it got stripped out. Trying again. Without php $ variable signs

Should this work?

request = "http://api.twittercounter.com/?apikey=5555555555555555555555555555&twitter_id=peeela"

response = file_get_contents(request)

p̶e̶e̶e̶l̶a̶

Posted on 7th of April 2010, 20:54 PM

A working example, with dummy details on the API page might be useful?

p̶e̶e̶e̶l̶a̶

Posted on 7th of April 2010, 21:35 PM

i guess CURL is the best option

$request = "http://api.twittercounter.com/?apikey=". $tcc_apikey ."&twitter_id=" . $tw_twitter_user_id;
$session = curl_init($request);
// no html headers, just data
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// response
$response = curl_exec($session);
curl_close($session);

Arjen Schat

Posted on 8th of April 2010, 03:39 AM

Hi Andre,

The twitter_id in the request is the id of the user, not the username. We've choose this implementation because usernames can change over time. Twitter_id can't.

p̶e̶e̶e̶l̶a̶

Posted on 8th of April 2010, 03:50 AM

Thanks for the response. That makes perfect sense. It was my first ever attempt to use an API via CURL (newbs) in PHP so I thought it might be useful to share an explicit example on your API page?

Arjen Schat

Posted on 8th of April 2010, 04:01 AM

You are welcome, we'll update the docs so it is more clear.

p̶e̶e̶e̶l̶a̶

Posted on 8th of April 2010, 04:22 AM

Nice FAQ design too. Like the Answered change of colour in the questions list view and the little answer on the question view. Very intuitive. You're own design or a plugin or "inspired" by another site?

Arjen Schat

Posted on 8th of April 2010, 04:44 AM

We used getsatisfaction, but that was just horrible. Because you have to sign in now with your twitter account, in most cases we have all the info we need. On getsatisfaction, our first question was: what is your twitter account.

The design is based on 37signals answers.

p̶e̶e̶e̶l̶a̶

Posted on 8th of April 2010, 09:06 AM

We've been wanting to use a "simple" version of get satisfaction - it's quite OTT really. Less features in that plugin would be a good thing.

Add a Comment

Please login in order to leave a comment.