GithubHelp home page GithubHelp logo

Comments (12)

lucaschevalierr avatar lucaschevalierr commented on July 24, 2024 1

I think you have an authentication issue. To use that API you need client credentials and user credentials. You would want to use the the values with the following names. You'd also need to make sure that the user has granted write permissions for that token and if the user had previously granted read only permissions, the app needs to be revoked and authorized again.

$connection = new TwitterOAuth('API Key', 'API Secret', 'Access Token', 'Access Token Secret');

OMG, the last time I created the token I didn't have the right permissions, I didn't see that it was here.

image

Thank you and really sorry...

from twitteroauth.

ProdigyView avatar ProdigyView commented on July 24, 2024

Same here. My code

<?php

require "vendor/autoload.php";

use Abraham\TwitterOAuth\TwitterOAuth;


$connection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken, $accessTokenSecret);

$connection->setApiVersion(1.1);
$connection->setTimeouts(10, 15);

$media1 = $connection->upload('media/upload', ['media' => '/code/test.mp4','media_type' => 'video/mp4', 'media_category' => 'tweet_video']);


print_r($media1);
print_r("Why are you null?");

$connection->setApiVersion(2);
$parameters = [
    'text' => 'Meow Meow Meow',
    'media' => ['media_ids' => [$media1->media_id_string]]
];
$result = $connection->post('tweets', $parameters);

from twitteroauth.

ProdigyView avatar ProdigyView commented on July 24, 2024

@lucaschevalierr Solved it! Use the chunk upload.

$media1 = $connection->upload('media/upload', ['media' => '/code/test.mp4','media_type' => 'video/mp4', 'media_category' => 'tweet_video'], ['chunkedUpload' => true]);

from twitteroauth.

lucaschevalierr avatar lucaschevalierr commented on July 24, 2024

@ProdigyView It doesn't work for me...
I try to do this :

$media = $connection->upload(
            'media/upload',
            [
                'media' => 'imgs/test.jpeg',
                'media_type' => 'image/jpeg',
                'media_category' => 'tweet_image'
            ],
            ['chunkedUpload' => true]
        );

And i have this error : property_exists(): Argument #1 ($object_or_class) must be of type object|string, null given

from twitteroauth.

ProdigyView avatar ProdigyView commented on July 24, 2024

I would the the absolute page to your image:

'media' => 'imgs/test.jpeg',

from twitteroauth.

lucaschevalierr avatar lucaschevalierr commented on July 24, 2024

I would the the absolute page to your image:

'media' => 'imgs/test.jpeg',

I already try, but it doesn't work either

from twitteroauth.

lucaschevalierr avatar lucaschevalierr commented on July 24, 2024

Anyone have an idea?

from twitteroauth.

abraham avatar abraham commented on July 24, 2024

And i have this error : property_exists(): Argument #1 ($object_or_class) must be of type object|string, null given

What's the rest of the error? What method is getting an invalid value?

from twitteroauth.

lucaschevalierr avatar lucaschevalierr commented on July 24, 2024

And i have this error : property_exists(): Argument #1 ($object_or_class) must be of type object|string, null given

What's the rest of the error? What method is getting an invalid value?

Here is the rest of the error :
image

from twitteroauth.

abraham avatar abraham commented on July 24, 2024

If you are not on the latest version of TwitterOAuth you would need to use the old method of setting chunkedUpload

$media = $connection->upload(
            'media/upload',
            [
                'media' => 'imgs/test.jpeg',
                'media_type' => 'image/jpeg',
                'media_category' => 'tweet_image'
            ],
            true
        );

from twitteroauth.

lucaschevalierr avatar lucaschevalierr commented on July 24, 2024

If you are not on the latest version of TwitterOAuth you would need to use the old method of setting chunkedUpload

$media = $connection->upload(
            'media/upload',
            [
                'media' => 'imgs/test.jpeg',
                'media_type' => 'image/jpeg',
                'media_category' => 'tweet_image'
            ],
            true
        );

So I ran some tests:

  • When I use the Client ID and Client Secret in the variables $consumerKey and $consumerSecret WITH ['chunkedUpload' => true], I get this error:
    Correction

  • When I use the Client ID and Client Secret in the variables $consumerKey and $consumerSecret WITHOUT ['chunkedUpload' => true], I get this error:
    Correction (1)

  • When I use the API Key and API Key secret in the variables $consumerKey and $consumerSecret WITH ['chunkedUpload' => true], I get this error:
    Correction (2)

  • When I use the API Key and API Key secret in the variables $consumerKey and $consumerSecret WITHOUT ['chunkedUpload' => true], I get "null":
    Correction (4)

PS: I think I am using the latest version of TwitterOAuth because when I try your code, I get this error: "Expected type 'array'. Found 'true'.”
Correction (3)

PS2: Thank you very much for the time you spend helping me.

from twitteroauth.

abraham avatar abraham commented on July 24, 2024

I think you have an authentication issue. To use that API you need client credentials and user credentials. You would want to use the the values with the following names. You'd also need to make sure that the user has granted write permissions for that token and if the user had previously granted read only permissions, the app needs to be revoked and authorized again.

$connection = new TwitterOAuth('API Key', 'API Secret', 'Access Token', 'Access Token Secret');

from twitteroauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.