Closed vignestion closed 8 years ago
have you try var_dump($followers) ; and check its property?
It return me like this
object(stdClass)[21] public 'errors' => array (size=1) 0 => object(stdClass)[26] public 'message' => string 'Sorry, that page does not exist' (length=31) public 'code' => int 34
public 'message' => string 'Sorry, that page does not exist'
This message is explaining everything.
You should change $connection->get('https://api.twitter.com/1.1/followers/ids.json?user_id='.$username); to $connection->get('https://api.twitter.com/1.1/followers/ids.json', ['user_id' => $username]);
GET and POST parameters are set to array :) check https://twitteroauth.com/
Ya i see that documentation But no luck it returns me a error like this. Fatal error: Cannot use object of type stdClass as array in C:\wamp\www\hy\index.php on line 89 This is my query $followers = $connection->get('https://api.twitter.com/1.1/followers/ids.json?',["screen_name" => $username]);
Sorry. I forgot write URL rules. Documentation wrote :
HTTP GET https://api.twitter.com/1.1/search/tweets.json?q=twitterapi TwitterOAuth $statuses = $connection->get("search/tweets", ["q" => "twitterapi"]);
No "https://api.twitter.com/1.1/" and ".json" extension. So you just replace this.
get('followers/ids', ["screen_name" => $username]);
The truth is no one will reply me again and again But you are great But this time also no luck.It returns me an another error. Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW) in C:\wamp\www\hy\index.php on line 82.
I think that => operator is prolem So I changed that to '->' again same error $followers = $connection->get('followers/ids',["screen_name"] => $username));
This is fundamental PHP coding and entirely unrelated to this library. Check out Dev Shed's PHP forum or maybe Stack Overflow. You'll get a lot more help with basic PHP stuff because that's what those sites are geared toward. The purpose here is to find and repair bugs within twitteroauth.
You are correct i am not good at php.But you are good at it right if it so.Please sove this issue.
["screen_name"] => $username
is not a valid PHP array. There are several examples of the proper syntax in the PHP docs.
Please help me to Solve this issue Here is my code.
<?php
//require_once 'config.php';
require "twitteroauth-master/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
ini_set('display_errors',1); error_reporting(-1);
define("CONSUMER_KEY", ""); define("CONSUMER_SECRET", ""); define("OAUTH_TOKEN", ""); define("OAUTH_SECRET", ""); /$username = 'vignestion'; //Your twitter screen name or page name $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET); $followers = $connection->get('https://api.twitter.com/1.1/users/show.json?screen_name='.$username); $followers = json_decode($followers,true); $f = $followers['followers_count']; echo $f; / $username = 'Kodeordie';
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, OAUTH_TOKEN, OAUTH_SECRET); $followers = $connection->get('https://api.twitter.com/1.1/followers/ids.json?user_id='.$username); echo ($followers->followers_count);
?>