Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Exception: No URL set! in TwitterAPIExchange.php:275 #276

Open
yudazdk opened this issue Feb 15, 2019 · 12 comments
Open

Uncaught Exception: No URL set! in TwitterAPIExchange.php:275 #276

yudazdk opened this issue Feb 15, 2019 · 12 comments

Comments

@yudazdk
Copy link

yudazdk commented Feb 15, 2019

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(); ?>

@J7mbo
Copy link
Owner

J7mbo commented Feb 15, 2019

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?

@yudazdk
Copy link
Author

yudazdk commented Feb 15, 2019

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

@yudazdk
Copy link
Author

yudazdk commented Feb 15, 2019

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(); ?>

@yudazdk
Copy link
Author

yudazdk commented Feb 15, 2019

Could that be authentication with my tokens ?

@yudazdk
Copy link
Author

yudazdk commented Feb 15, 2019

@J7mbo Could you help me ?
I run the code on xampp.

@J7mbo
Copy link
Owner

J7mbo commented Feb 15, 2019

I just ran the code you pasted above and it works perfectly.

@yudazdk
Copy link
Author

yudazdk commented Feb 15, 2019

I run it on Xampp.
What could be the problem ?

@yudazdk
Copy link
Author

yudazdk commented Feb 15, 2019

@J7mbo Did you run the code with the same tokens as mine ?

@J7mbo
Copy link
Owner

J7mbo commented Feb 15, 2019

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.

@yudazdk
Copy link
Author

yudazdk commented Feb 15, 2019

Do you mrun it on your local host ?
Do you use Xampp ?

@J7mbo
Copy link
Owner

J7mbo commented Feb 15, 2019

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?

@yudazdk
Copy link
Author

yudazdk commented Feb 15, 2019

I have.
It prints hello world.

In twitter developer app configuration
what should be the value of callback url ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants