2

My php/Yii application interacts with twilio. I know the sid of a queue. I want to get the current size of that queue. The thing is that I can't use the twilio php library (I don't want to get into the details). I'm using curl, but I keep getting 401 errors.

This is my code:

$curl = curl_init();
curl_setopt_array($curl,array(
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_URL => 'https://api.twilio.com/2010-04-01/Accounts/AccountId/Queues/QUeueID.json',
    CURLOPT_USERPWD => 'token:{AuthToken}'));
curl_exec($curl);

I don't what I'm doing wrong. I'm trying to follow the documentation:

http://www.twilio.com/docs/api/rest/queue

EDIT: I turned it into a get request, from a post request.

Also, I got a 401 unauthorized error, not a 411. Sorry about that. Typo.

SECOND EDIT:

So, I figured it out in a conversation with Kevin. Turns out that I needed:

CURLOPT_USERPWD => 'AccountID:Token' 
4

1 に答える 1

2

キューのサイズを取得しようとしているだけの場合は、POSTではなくGETリクエストを作成する必要があります。curlリクエストでCURLOPT_POSTを設定しているようです。

于 2013-02-19T21:21:13.300 に答える