Cannot create list - The list failed validation: A list's name can't be blank

php

#1

I’m stuck! :frowning: I’m hoping some of you guys might be able to point me in the right direction. I’m using TwitterAPIExchange to successfully perform GETs and POSTs against various APIs. But when trying to create a Twitter list, I keep getting the error:

“The list failed validation: A list’s name can’t be blank.”

I know name is a required field - I AM supplying the name value (at least I’m supplying it how I supply other params for a POST) yet it keeps giving me the above error.

My code looks like this:

<?php
require_once('TwitterAPIExchange.php');
require_once('GetSharedParams.php');

$settings = array(
    'oauth_access_token' => $oat,
    'oauth_access_token_secret' => $oats,
    'consumer_key' => $ck,
    'consumer_secret' => $cs
);

$url = 'https://api.twitter.com/1.1/lists/create.json';
$requestMethod = 'POST';

$postfields = array(
	'name' => 'test',
	'mode' => 'public'
	);

$twitter = new TwitterAPIExchange($settings);

echo $twitter->buildOauth($url, $requestMethod)
              ->setPostfields($postfields)
              ->performRequest();    

?>

Am I doing something wrong? I’m blind to this now having stared at it for so long! Any help you can give would be appreciated. Thanks


#2

This is the complete response:

object(stdClass)#2 (1) { ["errors"]=> array(1) { [0]=> object(stdClass)#3 (2) { ["code"]=> int(85) ["message"]=> string(57) "The list failed validation: A list's name can't be blank." } } } }

#3

OK guys. I figured it out. The code was fine. I think it was an issue with the TwitterAPIExchange. I updated it to the latest version - then got a different error complaining:

Uncaught exception ‘Exception’ with message 'SSL certificate problem: unable to get local issuer certificate

I added the following line to the TwitterAPIExchange file and we are now back in business:

curl_setopt($feed, CURLOPT_SSL_VERIFYPEER, false);

If anyone knows more about this issue and would care to explain it, I would definitely benefit from a better understanding - as might anyone else coming across this post.

Thanks :smile: