Open yudazdk opened 5 years ago
I just copied and pasted the code just before you edit it, and ran it on my machine, with the tokens you had, and got a result. Can you elaborate on what your error is?
I displayed the errors by ini_set('display_errors', true);
Before I did that I got the error: Error Code 32: Could not authenticate you
This is the code:
require_once('TwitterAPIExchange.php');
/ Set access tokens here - see: https://dev.twitter.com/apps/ / $settings = array( 'consumer_key' => "noV7y6jDK9eG68iE217UwgwdA", 'consumer_secret' => "7cQp5E9JZguNZ2PBMq62l36tsxuKild5LOyKYQG4K6k5gXchaR", 'oauth_access_token' => "14597778-MyxcqNfnlBvNM9mGQzf6yxzxdnEkm3mBFmJQbhwpu", 'oauth_access_token_secret' => "7Kx9VLglBRJrVnAOkll4LFYU9hXnIspybDuRBMLH7T0Qg" );
/ Perform a GET request and echo the response / / Note: Set the GET field BEFORE calling buildOauth(); /
$url = 'https://api.twitter.com/1.1/followers/ids.json'; $getfield = '?screen_name=J7mbo'; $requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings); echo $twitter->setGetfield($getfield) ->buildOauth($url, $requestMethod) ->performRequest(); ?>
Could that be authentication with my tokens ?
@J7mbo Could you help me ? I run the code on xampp.
I just ran the code you pasted above and it works perfectly.
I run it on Xampp. What could be the problem ?
@J7mbo Did you run the code with the same tokens as mine ?
Yes. I copied the code from this message, changed nothing, and I get a response back.
I would suggest clearing any cache, restarting your web server, and make a change at the top like echo "HELLO WORLD";
just to make sure that you are editing the correct file being served by your webserver.
Do you mrun it on your local host ? Do you use Xampp ?
Nope, I just ran it on localhost by typing php script.php
with your code in it and it worked perfectly. This is why I suggest that there is something else causing your problem.
You can disprove that your problem is a caching one by putting:
echo "hello world";
at the top of your php file and then refreshing your page and seeing if hello world is printed.
If it's not, then there's the problem you need to figure out. Have you done this?
I have. It prints hello world.
In twitter developer app configuration what should be the value of callback url ?
I wrote the following code and got this issue:
ini_set('display_errors', true);
ini_set('display_errors', 1); require_once('TwitterAPIExchange.php');
/ Set access tokens here - see: https://dev.twitter.com/apps/ / $settings = array( 'consumer_key' => "", 'consumer_secret' => "", 'oauth_access_token' => "", 'oauth_access_token_secret' => "" );
/ Perform a GET request and echo the response / / Note: Set the GET field BEFORE calling buildOauth(); /
$url = 'https://api.twitter.com/1.1/followers/ids.json'; $getfield = '?screen_name=J7mbo'; $requestMethod = 'GET';
$twitter = new TwitterAPIExchange($settings); echo $twitter->setGetfield($getfield) ->buildOauth($url, $requestMethod) ->performRequest(); ?>