abraham / twitteroauth

The most popular PHP library for use with the Twitter OAuth REST API.
https://twitteroauth.com
MIT License
4.3k stars 1.71k forks source link

How to install manually #933

Closed Markismx1 closed 3 years ago

Markismx1 commented 3 years ago

I don't have composer, and I don't plan to use it. I'm just trying to implement a simple tweet bot to post links to articles from my website to twitter. My website is on a hosting provider. So can you please tell me how to install manually?

abraham commented 3 years ago
  1. Download the latest release.
  2. Unpack the source code
  3. Require autoload.php
Markismx1 commented 3 years ago

I get the following error when using that method...

Fatal error: Uncaught Error: Class "Composer\CaBundle\CaBundle" not found in C:\xampp\htdocs\nnrsd\handlers\vendor\src\TwitterOAuth.php:572 Stack trace: #0 C:\xampp\htdocs\nnrsd\handlers\vendor\src\TwitterOAuth.php(620): Abraham\TwitterOAuth\TwitterOAuth->curlOptions() #1 C:\xampp\htdocs\nnrsd\handlers\vendor\src\TwitterOAuth.php(557): Abraham\TwitterOAuth\TwitterOAuth->request('https://api.twi...', 'GET', 'Authorization: ...', Array, false) #2 C:\xampp\htdocs\nnrsd\handlers\vendor\src\TwitterOAuth.php(490): Abraham\TwitterOAuth\TwitterOAuth->oAuthRequest('https://api.twi...', 'GET', Array, false) #3 C:\xampp\htdocs\nnrsd\handlers\vendor\src\TwitterOAuth.php(467): Abraham\TwitterOAuth\TwitterOAuth->makeRequests('https://api.twi...', 'GET', Array, false) #4 C:\xampp\htdocs\nnrsd\handlers\vendor\src\TwitterOAuth.php(232): Abraham\TwitterOAuth\TwitterOAuth->http('GET', 'https://api.twi...', 'account/verify...', Array, false) #5 C:\xampp\htdocs\nnrsd\handlers\twitter.php(12): Abraham\TwitterOAuth\TwitterOAuth->get('account/verify...') #6 {main} thrown in C:\xampp\htdocs\nnrsd\handlers\vendor\src\TwitterOAuth.php on line 572

abraham commented 3 years ago

You'll have to manually install ca-bundle as well. I'd recommend you install using composer on another machine and deploy the vendor directory from that install. It'll be much easier.

qcybb commented 1 year ago

I was looking for the same solution, so I hope this helps someone out.

Here's how to use twitteroauth without composer:

Grab both of these packages and extract them to a directory - I used /includes/

https://github.com/abraham/twitteroauth
https://github.com/composer/ca-bundle

Then in your PHP file, use:

require_once('/path/to/includes/ca-bundle/src/CaBundle.php');
require_once('/path/to/includes/twitteroauth/autoload.php');

use Abraham\TwitterOAuth\TwitterOAuth;

$connection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);
$content = $connection->get("account/verify_credentials");
print_r($content);

If you see any output, you know it's working.

jwafal commented 12 months ago

I could do with some help on this too! Ive tried the method above without success ... any pointers? Heres my php code:

`<?php

$CONSUMER_KEY = 'xxxx'; $CONSUMER_SECRET = 'xxxx'; $access_token = 'xxxx'; $access_token_secret = 'xxxx';

require_once('twit_includes/ca-bundle-main/src/CaBundle.php'); require_once('twit_includes/twitteroauth-main/autoload.php');

use Abraham\TwitterOAuth\TwitterOAuth;

$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $access_token, $access_token_secret); $content = $connection->get("account/verify_credentials"); print_r($content);

?>`

qcybb commented 12 months ago

What does you error log show?

jwafal commented 12 months ago

Don't get an error - must stress, Im front-end usually so dont know much about PHP (hence not wanting to use composer).. but have checked hosting logs and its not showing any errors

qcybb commented 12 months ago

Hmm .. without any errors, it's hard to know what's going on. I know I had an issue where I had to re-create the consumer key and access tokens for it to work.

jwafal commented 11 months ago

ok, thats an idea... i'll try that. Thanks for your thoughts!