Search code examples
phpcurltwitteroauthtwitter-oauth

get a list of suggested people on twitter from twitteroauth in php


I have the following code which I am trying to get users from. I am using twitteroauth which I got from twitteroauth.com This is my code

require "twitteroauth/autoload.php";

use Abraham\TwitterOAuth\TwitterOAuth;

$connection = new TwitterOAuth("xxxxx", "xxxxx", "xxxxxxx", "xxxxxxx");

$content = $connection->get("account/verify_credentials");

$users = $connection->get("users/suggestions/:slug", ["slug"=>"sports"]);

print_r($users);

I get the following error:

stdClass Object
(
    [errors] => Array
        (
            [0] => stdClass Object
                (
                    [code] => 34
                    [message] => Sorry, that page does not exist.
                )

        )

)

What am I doing wrong? I read the docs on twitter dev page https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-suggestions-slug

thank you in advance for your help


Solution

  • I found a solution to this

    :slug is a placeholder of where to put the value. You want one of the following:

    $connection->get("users/suggestions/sports");