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

How to extends functionality of any provider? #100

Closed
githubov opened this issue Oct 18, 2019 · 4 comments
Closed

How to extends functionality of any provider? #100

githubov opened this issue Oct 18, 2019 · 4 comments

Comments

@githubov
Copy link

I am very new with I success full login with any provide.
but twitter image upload use different api.
I want to extend functionality of Twitter provider class with my custom one without change core file.
if I update SocialConnect/auth feature maybe I lost my customization.
I need help on this.

Thank You.
Great PHP LIB SocialConnect/auth

@ovr
Copy link
Member

ovr commented Oct 18, 2019

Hey!

I didn't understand nothing, can you clarify what are you trying to reach and where is a problem
You can mention code/examples

Thanks

@githubov
Copy link
Author

Code are all right I need to add some methods on Provider Twitter class so that it can upload image and make a tweet.

@ovr
Copy link
Member

ovr commented Oct 21, 2019

I highly recommend creating an external class called service and don't try to create a provider that extends twitter one

Example

<?php

use SocialConnect\OAuth1\AccessToken;
use SocialConnect\OAuth1\Provider\Twitter;

class TwitterService
{
    /**
     * @var Twitter
     */
    protected $twitter;

    /**
     * MyAwesomeServiceThatWorksWithTwitter constructor.
     * @param Twitter $twitter
     */
    public function __construct(Twitter $twitter)
    {
        $this->twitter = $twitter;
    }

    public function doSomething(AccessToken $token)
    {
        $this->twitter->request('POST', '/upload', [], $token, [
            'image' => 'heh'
        ]);
    }
}

All provider has public request method that will help you to do requests

@ovr
Copy link
Member

ovr commented Jan 24, 2020

I am going close this issue because example was provided above and no replies

Thanks

@ovr ovr closed this as completed Jan 24, 2020
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