Ask a question

Add a comment

← All questions


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

p̶e̶e̶e̶l̶a̶ 07-Apr-2010 20:44:53

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

p̶e̶e̶e̶l̶a̶ 07-Apr-2010 20:48:34

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

Should this work?

request = ""

response = file_get_contents(request)

p̶e̶e̶e̶l̶a̶ 07-Apr-2010 20:54:57

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

p̶e̶e̶e̶l̶a̶ 07-Apr-2010 21:35:33

i guess CURL is the best option

$request = "". $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);

Arjen Schat 08-Apr-2010 03:39:34

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̶ 08-Apr-2010 03:50:57

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 08-Apr-2010 04:01:56

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

p̶e̶e̶e̶l̶a̶ 08-Apr-2010 04:22:14

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 08-Apr-2010 04:44:22

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̶ 08-Apr-2010 09:06:36

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 first to add a comment.
By logging in we now who you are on twitter. This helps us helping you faster and better.