FS Poster - Best Auto Poster & Scheduler Plugin For WordPress

FS Poster — Auto Poster & Scheduler Plugin For WordPress v7.1.9

No permission to download

Lancel

New member
Oct 29, 2019
15
2
3
hey guys i remember couple of months ago a previous version of the plugin was supporting to url shortener service but this version doesnt appear bitly and tinyurl when i enable url shortener from the admin panel. Anyone else facing with this problem?

Also when i use pinterest to post i get an error "could not upload the image" any suggestion how to fix it?
 
Last edited:

lgokul

Well-known member
Babiato Lover
Null Master
Trusted Uploader
Jun 26, 2019
998
1,600
93
32
Planeta Vegeta
hey guys i remember couple of months ago a previous version of the plugin was supporting to url shortener service but this version doesnt appear bitly and tinyurl when i enable url shortener from the admin panel. Anyone else facing with this problem?

Also when i use pinterest to post i get an error "could not upload the image" any suggestion how to fix it?
Could you post the error that comes out regarding the shortened URL?

The second is what version do you currently have installed?

Use version 3.6.1 V3 for pinterest.
 

guru

New member
May 24, 2019
27
5
3
I need more information...
In which social network, some screenshot.
What version of fs poster do you use, etc.

Only Text Message (test) Comes not video -- I m using ver
3.6.1 V3
 

Attachments

  • facebook.png
    facebook.png
    7.2 KB · Views: 8
  • linkedin.png
    linkedin.png
    9.2 KB · Views: 8
  • twitter.png
    twitter.png
    3.2 KB · Views: 7

lgokul

Well-known member
Babiato Lover
Null Master
Trusted Uploader
Jun 26, 2019
998
1,600
93
32
Planeta Vegeta

Lancel

New member
Oct 29, 2019
15
2
3
pin.jpg
in this version i can successfully add pinterest account with cookie method and connected a board however when i share a post or manually share from fs poster admin panel i get the error that could not upload the image, any suggestions?
 

lgokul

Well-known member
Babiato Lover
Null Master
Trusted Uploader
Jun 26, 2019
998
1,600
93
32
Planeta Vegeta
pin.jpg
in this version i can successfully add pinterest account with cookie method and connected a board however when i share a post or manually share from fs poster admin panel i get the error that could not upload the image, any suggestions?
Did you use version 3.6.2?
 
  • Like
Reactions: Lancel

lgokul

Well-known member
Babiato Lover
Null Master
Trusted Uploader
Jun 26, 2019
998
1,600
93
32
Planeta Vegeta
Go to:
fs-poster/App/Lib/pinterest/PinterestCookieApi.php


Replace all content:
Code:
<?php

namespace FSPoster\App\Lib\pinterest;

use FSPoster\App\Providers\Helper;
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;

class PinterestCookieApi
{

    /**
     * @var \GuzzleHttp\Client
     */
    private $client;

    public function __construct( $cookie , $proxy )
    {
        $csrf_token = base64_encode( microtime(1) . rand(0, 99999) );

        $cookieJar  = new CookieJar(false , [
            ["Name" => "_pinterest_sess", "Value"  => $cookie,  "Domain" => ".pinterest.com","Path" => "/","Max-Age" => null,"Expires" => null,"Secure" => false,"Discard" => false,"HttpOnly" => false,"Priority" => "HIGH"],
            ["Name" => "csrftoken", "Value"  => $csrf_token,  "Domain" => ".pinterest.com","Path" => "/","Max-Age" => null,"Expires" => null,"Secure" => false,"Discard" => false,"HttpOnly" => false,"Priority" => "HIGH"]
        ]);

        $this->client    = new Client([
            'cookies'             =>    $cookieJar,
            'allow_redirects'    =>    [ 'max' => 10 ],
            'proxy'                =>    empty($proxy) ? null : $proxy,
            'verify'            =>    false,
            'http_errors'        =>    false,
            'headers'            =>    [
                'User-Agent'    => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0' ,
                'x-CSRFToken'   =>  $csrf_token
            ]
        ]);
    }

    public function sendPost( $boardId , $title, $message , $link , $images )
    {
        $imageUrl = reset($images);
        if( empty( $imageUrl ) )
        {
            return [
                'status'    =>    'error',
                'error_msg'    =>    esc_html__('Image not fount for pin to board!')
            ];
        }

        $uploadedImage = $this->uploadImage( $imageUrl );
        if( $uploadedImage[0] == false )
        {
            return [
                'status'    =>    'error',
                'error_msg'    =>    $uploadedImage[1]
            ];
        }

        $sendData = [
            "options"   =>  [
                "board_id"              =>  $boardId,
                "field_set_key"         =>  "create_success",
                "skip_pin_create_log"   =>  true,
                "description"           =>  $message,
                "link"                  =>  $link,
                "title"                 =>  $title,
                "image_url"             =>  $uploadedImage[1],
                "method"                =>  "uploaded",
                "upload_metric"         =>   ["source"  =>  "pinner_upload_standalone"]
            ],
            "context" =>  []
        ];

        try
        {
            $response = (string)$this->client->post( 'https://www.pinterest.com/resource/PinResource/create/' , [
                'form_params' => [
                    'data'  =>    json_encode( $sendData )
                ]
            ])->getBody();
            $response = json_decode( $response, true );
        }
        catch( \Exception $e )
        {
            $response = [];
        }

        $pinId = isset( $response['resource_response']['data']['id'] ) ? $response['resource_response']['data']['id'] : '';
        if( empty( $pinId ) )
        {
            return [
                'status'    => 'error',
                'error_msg'    => isset($result['resource_response']['message']) ? esc_html($result['resource_response']['message']) : esc_html__('Could not upload the image!')
            ];
        }
        else
        {
            return [
                'status'    => 'ok',
                'id'        => $pinId
            ];
        }
    }

    private function uploadImage( $image )
    {
        try
        {
            $response = (string)$this->client->post( 'https://www.pinterest.com/upload-image/' , [
                'multipart'    =>    [
                    [
                        'name'      => 'img',
                        'contents'  => file_get_contents( $image ),
                        'filename'  => 'blob',
                        'headers'   => ['Content-Type' => 'image/jpeg']
                    ]
                ]
            ])->getBody();
            $response = json_decode( $response, true );
        }
        catch( \Exception $e )
        {
            return [ false, $e->getMessage() ];
        }

        return isset( $response['image_url'] ) ? [ true, $response['image_url'] ] : [ false, ( isset($result['resource_response']['message']) ? $result['resource_response']['message'] : esc_html__('Could not upload the image!') ) ];
    }

    public function getAccountData( )
    {
        try
        {
            $response = (string)$this->client->get( 'https://www.pinterest.com/resource/HomefeedBadgingResource/get/' )->getBody();
        }
        catch( \Exception $e )
        {
            $response = '';
        }

        $result = json_decode( $response, true );

        $id         = isset($result['client_context']['user']['id']) ? $result['client_context']['user']['id'] : '';
        $image      = isset($result['client_context']['user']['image_medium_url']) ? $result['client_context']['user']['image_medium_url'] : '';
        $username   = isset($result['client_context']['user']['username']) ? $result['client_context']['user']['username'] : '';
        $full_name  = isset($result['client_context']['user']['full_name']) ? $result['client_context']['user']['full_name'] : '';

        if( empty( $id ) || empty( $username ) )
        {
            Helper::response( false, isset($result['resource_response']['message']) ? esc_html($result['resource_response']['message']) : esc_html__('Error! Please check the data and try again!', 'fs-poster') );
        }

        return [
            'id'            =>    $id,
            'full_name'        =>    $full_name,
            'profile_pic'    =>    $image,
            'username'        =>    $username
        ];
    }

    public function getBoards( $userName )
    {
        $data = [
            "options"   =>  [
                "isPrefetch"            =>  false,
                "privacy_filter"        =>  "all",
                "sort"                  =>  "custom",
                "field_set_key"         =>  "profile_grid_item",
                "username"              =>  $userName,
                "page_size"             =>  25,
                "group_by"              =>  "visibility",
                "include_archived"      =>  true,
                "redux_normalize_feed"  =>  true
            ],
            "context"   =>  []
        ];

        $boardsArr = [];
        $bookmark = '';

        while( true )
        {
            if( !empty( $bookmark ) )
            {
                $data['options']['bookmarks'] = [ $bookmark ];
            }

            try
            {
                $response = (string)$this->client->get( 'https://www.pinterest.com/resource/BoardsResource/get/?data=' . urlencode( json_encode( $data ) ) )->getBody();
                $response = json_decode( $response, true );
            }
            catch( \Exception $e )
            {
                $response = [];
            }

            if( !isset( $response['resource_response']['data'] ) || !is_array( $response['resource_response']['data'] ) )
            {
                $boards = [];
            }
            else
            {
                $boards = $response['resource_response']['data'];
            }

            foreach ( $boards AS $board )
            {
                $boardsArr[] = [
                    'id'    =>  $board['id'],
                    'name'  =>  $board['name'],
                    'url'   =>  ltrim( $board['url'], '/' ),
                    'cover' =>  isset($board['image_cover_url']) ? $board['image_cover_url'] : ''
                ];
            }

            if( isset( $response['resource_response']['bookmark'] ) && is_string( $response['resource_response']['bookmark'] ) && !empty( $response['resource_response']['bookmark'] ) && $response['resource_response']['bookmark'] != '-end-' )
            {
                $bookmark = $response['resource_response']['bookmark'];
            }
            else
            {
                break;
            }
        }

        return $boardsArr;
    }

}

And try now and report please
 
  • Like
Reactions: Lancel

leonelborges

Member
Feb 27, 2020
51
17
8
Go to:
fs-poster/App/Lib/pinterest/PinterestCookieApi.php


Replace all content:
Code:
<?php

namespace FSPoster\App\Lib\pinterest;

use FSPoster\App\Providers\Helper;
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;

class PinterestCookieApi
{

    /**
     * @var \GuzzleHttp\Client
     */
    private $client;

    public function __construct( $cookie , $proxy )
    {
        $csrf_token = base64_encode( microtime(1) . rand(0, 99999) );

        $cookieJar  = new CookieJar(false , [
            ["Name" => "_pinterest_sess", "Value"  => $cookie,  "Domain" => ".pinterest.com","Path" => "/","Max-Age" => null,"Expires" => null,"Secure" => false,"Discard" => false,"HttpOnly" => false,"Priority" => "HIGH"],
            ["Name" => "csrftoken", "Value"  => $csrf_token,  "Domain" => ".pinterest.com","Path" => "/","Max-Age" => null,"Expires" => null,"Secure" => false,"Discard" => false,"HttpOnly" => false,"Priority" => "HIGH"]
        ]);

        $this->client    = new Client([
            'cookies'             =>    $cookieJar,
            'allow_redirects'    =>    [ 'max' => 10 ],
            'proxy'                =>    empty($proxy) ? null : $proxy,
            'verify'            =>    false,
            'http_errors'        =>    false,
            'headers'            =>    [
                'User-Agent'    => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0' ,
                'x-CSRFToken'   =>  $csrf_token
            ]
        ]);
    }

    public function sendPost( $boardId , $title, $message , $link , $images )
    {
        $imageUrl = reset($images);
        if( empty( $imageUrl ) )
        {
            return [
                'status'    =>    'error',
                'error_msg'    =>    esc_html__('Image not fount for pin to board!')
            ];
        }

        $uploadedImage = $this->uploadImage( $imageUrl );
        if( $uploadedImage[0] == false )
        {
            return [
                'status'    =>    'error',
                'error_msg'    =>    $uploadedImage[1]
            ];
        }

        $sendData = [
            "options"   =>  [
                "board_id"              =>  $boardId,
                "field_set_key"         =>  "create_success",
                "skip_pin_create_log"   =>  true,
                "description"           =>  $message,
                "link"                  =>  $link,
                "title"                 =>  $title,
                "image_url"             =>  $uploadedImage[1],
                "method"                =>  "uploaded",
                "upload_metric"         =>   ["source"  =>  "pinner_upload_standalone"]
            ],
            "context" =>  []
        ];

        try
        {
            $response = (string)$this->client->post( 'https://www.pinterest.com/resource/PinResource/create/' , [
                'form_params' => [
                    'data'  =>    json_encode( $sendData )
                ]
            ])->getBody();
            $response = json_decode( $response, true );
        }
        catch( \Exception $e )
        {
            $response = [];
        }

        $pinId = isset( $response['resource_response']['data']['id'] ) ? $response['resource_response']['data']['id'] : '';
        if( empty( $pinId ) )
        {
            return [
                'status'    => 'error',
                'error_msg'    => isset($result['resource_response']['message']) ? esc_html($result['resource_response']['message']) : esc_html__('Could not upload the image!')
            ];
        }
        else
        {
            return [
                'status'    => 'ok',
                'id'        => $pinId
            ];
        }
    }

    private function uploadImage( $image )
    {
        try
        {
            $response = (string)$this->client->post( 'https://www.pinterest.com/upload-image/' , [
                'multipart'    =>    [
                    [
                        'name'      => 'img',
                        'contents'  => file_get_contents( $image ),
                        'filename'  => 'blob',
                        'headers'   => ['Content-Type' => 'image/jpeg']
                    ]
                ]
            ])->getBody();
            $response = json_decode( $response, true );
        }
        catch( \Exception $e )
        {
            return [ false, $e->getMessage() ];
        }

        return isset( $response['image_url'] ) ? [ true, $response['image_url'] ] : [ false, ( isset($result['resource_response']['message']) ? $result['resource_response']['message'] : esc_html__('Could not upload the image!') ) ];
    }

    public function getAccountData( )
    {
        try
        {
            $response = (string)$this->client->get( 'https://www.pinterest.com/resource/HomefeedBadgingResource/get/' )->getBody();
        }
        catch( \Exception $e )
        {
            $response = '';
        }

        $result = json_decode( $response, true );

        $id         = isset($result['client_context']['user']['id']) ? $result['client_context']['user']['id'] : '';
        $image      = isset($result['client_context']['user']['image_medium_url']) ? $result['client_context']['user']['image_medium_url'] : '';
        $username   = isset($result['client_context']['user']['username']) ? $result['client_context']['user']['username'] : '';
        $full_name  = isset($result['client_context']['user']['full_name']) ? $result['client_context']['user']['full_name'] : '';

        if( empty( $id ) || empty( $username ) )
        {
            Helper::response( false, isset($result['resource_response']['message']) ? esc_html($result['resource_response']['message']) : esc_html__('Error! Please check the data and try again!', 'fs-poster') );
        }

        return [
            'id'            =>    $id,
            'full_name'        =>    $full_name,
            'profile_pic'    =>    $image,
            'username'        =>    $username
        ];
    }

    public function getBoards( $userName )
    {
        $data = [
            "options"   =>  [
                "isPrefetch"            =>  false,
                "privacy_filter"        =>  "all",
                "sort"                  =>  "custom",
                "field_set_key"         =>  "profile_grid_item",
                "username"              =>  $userName,
                "page_size"             =>  25,
                "group_by"              =>  "visibility",
                "include_archived"      =>  true,
                "redux_normalize_feed"  =>  true
            ],
            "context"   =>  []
        ];

        $boardsArr = [];
        $bookmark = '';

        while( true )
        {
            if( !empty( $bookmark ) )
            {
                $data['options']['bookmarks'] = [ $bookmark ];
            }

            try
            {
                $response = (string)$this->client->get( 'https://www.pinterest.com/resource/BoardsResource/get/?data=' . urlencode( json_encode( $data ) ) )->getBody();
                $response = json_decode( $response, true );
            }
            catch( \Exception $e )
            {
                $response = [];
            }

            if( !isset( $response['resource_response']['data'] ) || !is_array( $response['resource_response']['data'] ) )
            {
                $boards = [];
            }
            else
            {
                $boards = $response['resource_response']['data'];
            }

            foreach ( $boards AS $board )
            {
                $boardsArr[] = [
                    'id'    =>  $board['id'],
                    'name'  =>  $board['name'],
                    'url'   =>  ltrim( $board['url'], '/' ),
                    'cover' =>  isset($board['image_cover_url']) ? $board['image_cover_url'] : ''
                ];
            }

            if( isset( $response['resource_response']['bookmark'] ) && is_string( $response['resource_response']['bookmark'] ) && !empty( $response['resource_response']['bookmark'] ) && $response['resource_response']['bookmark'] != '-end-' )
            {
                $bookmark = $response['resource_response']['bookmark'];
            }
            else
            {
                break;
            }
        }

        return $boardsArr;
    }

}

And try now and report please


Error continues: could not upload the image

Can I send ftp account to check
 
  • Like
Reactions: Lancel

Lancel

New member
Oct 29, 2019
15
2
3
Go to:
fs-poster/App/Lib/pinterest/PinterestCookieApi.php


Replace all content:
Code:
<?php

namespace FSPoster\App\Lib\pinterest;

use FSPoster\App\Providers\Helper;
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;

class PinterestCookieApi
{

    /**
     * @var \GuzzleHttp\Client
     */
    private $client;

    public function __construct( $cookie , $proxy )
    {
        $csrf_token = base64_encode( microtime(1) . rand(0, 99999) );

        $cookieJar  = new CookieJar(false , [
            ["Name" => "_pinterest_sess", "Value"  => $cookie,  "Domain" => ".pinterest.com","Path" => "/","Max-Age" => null,"Expires" => null,"Secure" => false,"Discard" => false,"HttpOnly" => false,"Priority" => "HIGH"],
            ["Name" => "csrftoken", "Value"  => $csrf_token,  "Domain" => ".pinterest.com","Path" => "/","Max-Age" => null,"Expires" => null,"Secure" => false,"Discard" => false,"HttpOnly" => false,"Priority" => "HIGH"]
        ]);

        $this->client    = new Client([
            'cookies'             =>    $cookieJar,
            'allow_redirects'    =>    [ 'max' => 10 ],
            'proxy'                =>    empty($proxy) ? null : $proxy,
            'verify'            =>    false,
            'http_errors'        =>    false,
            'headers'            =>    [
                'User-Agent'    => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0' ,
                'x-CSRFToken'   =>  $csrf_token
            ]
        ]);
    }

    public function sendPost( $boardId , $title, $message , $link , $images )
    {
        $imageUrl = reset($images);
        if( empty( $imageUrl ) )
        {
            return [
                'status'    =>    'error',
                'error_msg'    =>    esc_html__('Image not fount for pin to board!')
            ];
        }

        $uploadedImage = $this->uploadImage( $imageUrl );
        if( $uploadedImage[0] == false )
        {
            return [
                'status'    =>    'error',
                'error_msg'    =>    $uploadedImage[1]
            ];
        }

        $sendData = [
            "options"   =>  [
                "board_id"              =>  $boardId,
                "field_set_key"         =>  "create_success",
                "skip_pin_create_log"   =>  true,
                "description"           =>  $message,
                "link"                  =>  $link,
                "title"                 =>  $title,
                "image_url"             =>  $uploadedImage[1],
                "method"                =>  "uploaded",
                "upload_metric"         =>   ["source"  =>  "pinner_upload_standalone"]
            ],
            "context" =>  []
        ];

        try
        {
            $response = (string)$this->client->post( 'https://www.pinterest.com/resource/PinResource/create/' , [
                'form_params' => [
                    'data'  =>    json_encode( $sendData )
                ]
            ])->getBody();
            $response = json_decode( $response, true );
        }
        catch( \Exception $e )
        {
            $response = [];
        }

        $pinId = isset( $response['resource_response']['data']['id'] ) ? $response['resource_response']['data']['id'] : '';
        if( empty( $pinId ) )
        {
            return [
                'status'    => 'error',
                'error_msg'    => isset($result['resource_response']['message']) ? esc_html($result['resource_response']['message']) : esc_html__('Could not upload the image!')
            ];
        }
        else
        {
            return [
                'status'    => 'ok',
                'id'        => $pinId
            ];
        }
    }

    private function uploadImage( $image )
    {
        try
        {
            $response = (string)$this->client->post( 'https://www.pinterest.com/upload-image/' , [
                'multipart'    =>    [
                    [
                        'name'      => 'img',
                        'contents'  => file_get_contents( $image ),
                        'filename'  => 'blob',
                        'headers'   => ['Content-Type' => 'image/jpeg']
                    ]
                ]
            ])->getBody();
            $response = json_decode( $response, true );
        }
        catch( \Exception $e )
        {
            return [ false, $e->getMessage() ];
        }

        return isset( $response['image_url'] ) ? [ true, $response['image_url'] ] : [ false, ( isset($result['resource_response']['message']) ? $result['resource_response']['message'] : esc_html__('Could not upload the image!') ) ];
    }

    public function getAccountData( )
    {
        try
        {
            $response = (string)$this->client->get( 'https://www.pinterest.com/resource/HomefeedBadgingResource/get/' )->getBody();
        }
        catch( \Exception $e )
        {
            $response = '';
        }

        $result = json_decode( $response, true );

        $id         = isset($result['client_context']['user']['id']) ? $result['client_context']['user']['id'] : '';
        $image      = isset($result['client_context']['user']['image_medium_url']) ? $result['client_context']['user']['image_medium_url'] : '';
        $username   = isset($result['client_context']['user']['username']) ? $result['client_context']['user']['username'] : '';
        $full_name  = isset($result['client_context']['user']['full_name']) ? $result['client_context']['user']['full_name'] : '';

        if( empty( $id ) || empty( $username ) )
        {
            Helper::response( false, isset($result['resource_response']['message']) ? esc_html($result['resource_response']['message']) : esc_html__('Error! Please check the data and try again!', 'fs-poster') );
        }

        return [
            'id'            =>    $id,
            'full_name'        =>    $full_name,
            'profile_pic'    =>    $image,
            'username'        =>    $username
        ];
    }

    public function getBoards( $userName )
    {
        $data = [
            "options"   =>  [
                "isPrefetch"            =>  false,
                "privacy_filter"        =>  "all",
                "sort"                  =>  "custom",
                "field_set_key"         =>  "profile_grid_item",
                "username"              =>  $userName,
                "page_size"             =>  25,
                "group_by"              =>  "visibility",
                "include_archived"      =>  true,
                "redux_normalize_feed"  =>  true
            ],
            "context"   =>  []
        ];

        $boardsArr = [];
        $bookmark = '';

        while( true )
        {
            if( !empty( $bookmark ) )
            {
                $data['options']['bookmarks'] = [ $bookmark ];
            }

            try
            {
                $response = (string)$this->client->get( 'https://www.pinterest.com/resource/BoardsResource/get/?data=' . urlencode( json_encode( $data ) ) )->getBody();
                $response = json_decode( $response, true );
            }
            catch( \Exception $e )
            {
                $response = [];
            }

            if( !isset( $response['resource_response']['data'] ) || !is_array( $response['resource_response']['data'] ) )
            {
                $boards = [];
            }
            else
            {
                $boards = $response['resource_response']['data'];
            }

            foreach ( $boards AS $board )
            {
                $boardsArr[] = [
                    'id'    =>  $board['id'],
                    'name'  =>  $board['name'],
                    'url'   =>  ltrim( $board['url'], '/' ),
                    'cover' =>  isset($board['image_cover_url']) ? $board['image_cover_url'] : ''
                ];
            }

            if( isset( $response['resource_response']['bookmark'] ) && is_string( $response['resource_response']['bookmark'] ) && !empty( $response['resource_response']['bookmark'] ) && $response['resource_response']['bookmark'] != '-end-' )
            {
                $bookmark = $response['resource_response']['bookmark'];
            }
            else
            {
                break;
            }
        }

        return $boardsArr;
    }

}

And try now and report please

Hi Igokul,
Thanks for your time and support i really appreciate your effort. Yes, im using 3.6.2 version but i also tried former versions such as 3.6.1 and 3.6.0 and they gave the same error too. Im also trying to share from fs poster admin and still having same error occured. I can provide you wp admin and ftp informations if you need. Hop there will be a solution...
 

Lancel

New member
Oct 29, 2019
15
2
3
Go to:
fs-poster/App/Lib/pinterest/PinterestCookieApi.php


Replace all content:
Code:
<?php

namespace FSPoster\App\Lib\pinterest;

use FSPoster\App\Providers\Helper;
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;

class PinterestCookieApi
{

    /**
     * @var \GuzzleHttp\Client
     */
    private $client;

    public function __construct( $cookie , $proxy )
    {
        $csrf_token = base64_encode( microtime(1) . rand(0, 99999) );

        $cookieJar  = new CookieJar(false , [
            ["Name" => "_pinterest_sess", "Value"  => $cookie,  "Domain" => ".pinterest.com","Path" => "/","Max-Age" => null,"Expires" => null,"Secure" => false,"Discard" => false,"HttpOnly" => false,"Priority" => "HIGH"],
            ["Name" => "csrftoken", "Value"  => $csrf_token,  "Domain" => ".pinterest.com","Path" => "/","Max-Age" => null,"Expires" => null,"Secure" => false,"Discard" => false,"HttpOnly" => false,"Priority" => "HIGH"]
        ]);

        $this->client    = new Client([
            'cookies'             =>    $cookieJar,
            'allow_redirects'    =>    [ 'max' => 10 ],
            'proxy'                =>    empty($proxy) ? null : $proxy,
            'verify'            =>    false,
            'http_errors'        =>    false,
            'headers'            =>    [
                'User-Agent'    => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:75.0) Gecko/20100101 Firefox/75.0' ,
                'x-CSRFToken'   =>  $csrf_token
            ]
        ]);
    }

    public function sendPost( $boardId , $title, $message , $link , $images )
    {
        $imageUrl = reset($images);
        if( empty( $imageUrl ) )
        {
            return [
                'status'    =>    'error',
                'error_msg'    =>    esc_html__('Image not fount for pin to board!')
            ];
        }

        $uploadedImage = $this->uploadImage( $imageUrl );
        if( $uploadedImage[0] == false )
        {
            return [
                'status'    =>    'error',
                'error_msg'    =>    $uploadedImage[1]
            ];
        }

        $sendData = [
            "options"   =>  [
                "board_id"              =>  $boardId,
                "field_set_key"         =>  "create_success",
                "skip_pin_create_log"   =>  true,
                "description"           =>  $message,
                "link"                  =>  $link,
                "title"                 =>  $title,
                "image_url"             =>  $uploadedImage[1],
                "method"                =>  "uploaded",
                "upload_metric"         =>   ["source"  =>  "pinner_upload_standalone"]
            ],
            "context" =>  []
        ];

        try
        {
            $response = (string)$this->client->post( 'https://www.pinterest.com/resource/PinResource/create/' , [
                'form_params' => [
                    'data'  =>    json_encode( $sendData )
                ]
            ])->getBody();
            $response = json_decode( $response, true );
        }
        catch( \Exception $e )
        {
            $response = [];
        }

        $pinId = isset( $response['resource_response']['data']['id'] ) ? $response['resource_response']['data']['id'] : '';
        if( empty( $pinId ) )
        {
            return [
                'status'    => 'error',
                'error_msg'    => isset($result['resource_response']['message']) ? esc_html($result['resource_response']['message']) : esc_html__('Could not upload the image!')
            ];
        }
        else
        {
            return [
                'status'    => 'ok',
                'id'        => $pinId
            ];
        }
    }

    private function uploadImage( $image )
    {
        try
        {
            $response = (string)$this->client->post( 'https://www.pinterest.com/upload-image/' , [
                'multipart'    =>    [
                    [
                        'name'      => 'img',
                        'contents'  => file_get_contents( $image ),
                        'filename'  => 'blob',
                        'headers'   => ['Content-Type' => 'image/jpeg']
                    ]
                ]
            ])->getBody();
            $response = json_decode( $response, true );
        }
        catch( \Exception $e )
        {
            return [ false, $e->getMessage() ];
        }

        return isset( $response['image_url'] ) ? [ true, $response['image_url'] ] : [ false, ( isset($result['resource_response']['message']) ? $result['resource_response']['message'] : esc_html__('Could not upload the image!') ) ];
    }

    public function getAccountData( )
    {
        try
        {
            $response = (string)$this->client->get( 'https://www.pinterest.com/resource/HomefeedBadgingResource/get/' )->getBody();
        }
        catch( \Exception $e )
        {
            $response = '';
        }

        $result = json_decode( $response, true );

        $id         = isset($result['client_context']['user']['id']) ? $result['client_context']['user']['id'] : '';
        $image      = isset($result['client_context']['user']['image_medium_url']) ? $result['client_context']['user']['image_medium_url'] : '';
        $username   = isset($result['client_context']['user']['username']) ? $result['client_context']['user']['username'] : '';
        $full_name  = isset($result['client_context']['user']['full_name']) ? $result['client_context']['user']['full_name'] : '';

        if( empty( $id ) || empty( $username ) )
        {
            Helper::response( false, isset($result['resource_response']['message']) ? esc_html($result['resource_response']['message']) : esc_html__('Error! Please check the data and try again!', 'fs-poster') );
        }

        return [
            'id'            =>    $id,
            'full_name'        =>    $full_name,
            'profile_pic'    =>    $image,
            'username'        =>    $username
        ];
    }

    public function getBoards( $userName )
    {
        $data = [
            "options"   =>  [
                "isPrefetch"            =>  false,
                "privacy_filter"        =>  "all",
                "sort"                  =>  "custom",
                "field_set_key"         =>  "profile_grid_item",
                "username"              =>  $userName,
                "page_size"             =>  25,
                "group_by"              =>  "visibility",
                "include_archived"      =>  true,
                "redux_normalize_feed"  =>  true
            ],
            "context"   =>  []
        ];

        $boardsArr = [];
        $bookmark = '';

        while( true )
        {
            if( !empty( $bookmark ) )
            {
                $data['options']['bookmarks'] = [ $bookmark ];
            }

            try
            {
                $response = (string)$this->client->get( 'https://www.pinterest.com/resource/BoardsResource/get/?data=' . urlencode( json_encode( $data ) ) )->getBody();
                $response = json_decode( $response, true );
            }
            catch( \Exception $e )
            {
                $response = [];
            }

            if( !isset( $response['resource_response']['data'] ) || !is_array( $response['resource_response']['data'] ) )
            {
                $boards = [];
            }
            else
            {
                $boards = $response['resource_response']['data'];
            }

            foreach ( $boards AS $board )
            {
                $boardsArr[] = [
                    'id'    =>  $board['id'],
                    'name'  =>  $board['name'],
                    'url'   =>  ltrim( $board['url'], '/' ),
                    'cover' =>  isset($board['image_cover_url']) ? $board['image_cover_url'] : ''
                ];
            }

            if( isset( $response['resource_response']['bookmark'] ) && is_string( $response['resource_response']['bookmark'] ) && !empty( $response['resource_response']['bookmark'] ) && $response['resource_response']['bookmark'] != '-end-' )
            {
                $bookmark = $response['resource_response']['bookmark'];
            }
            else
            {
                break;
            }
        }

        return $boardsArr;
    }

}

And try now and report please
I have replaced the file as you provide with the one in there, however still getting could not upload image error :/
 

skypeleft

Active member
Aug 10, 2019
401
71
28
Hmm, this plugin to bad for reset all setting when i remove old version then install new version
 

lgokul

Well-known member
Babiato Lover
Null Master
Trusted Uploader
Jun 26, 2019
998
1,600
93
32
Planeta Vegeta
I have replaced the file as you provide with the one in there, however still getting could not upload image error :/
Ok friend, the problem is in the account settings.
Apparently pinterest has very limited to his country Brazil in terms of images.
If you change your country in the Pinterest settings for example to Peru or any other you will see how it is published successfully.

The language I left in Portuguese.
 
  • Like
Reactions: Lancel

lgokul

Well-known member
Babiato Lover
Null Master
Trusted Uploader
Jun 26, 2019
998
1,600
93
32
Planeta Vegeta
Hmm, this plugin to bad for reset all setting when i remove old version then install new version
Of course this is not an error, obviously if you delete the plugin from the wordpress control panel all the data will be deleted.
So that the data is not deleted and preserved, first deactivate the plugin via the wordpress panel and then delete the fs-poter folder of the wordpress wp-content and replace it with the new folder.

Then activate the plugin via the control panel.

If you have a very old version, I recommend installing from 0, removing the plugin from the control panel.
 

skypeleft

Active member
Aug 10, 2019
401
71
28
Of course this is not an error, obviously if you delete the plugin from the wordpress control panel all the data will be deleted.
So that the data is not deleted and preserved, first deactivate the plugin via the wordpress panel and then delete the fs-poter folder of the wordpress wp-content and replace it with the new folder.

Then activate the plugin via the control panel.

If you have a very old version, I recommend installing from 0, removing the plugin from the control panel.

No pro, i see some plugin not delete data on database when remove plugin.
 

About us

  • Our community has been around for many years and pride ourselves on offering unbiased, critical discussion among people of all different backgrounds. We are working every day to make sure our community is one of the best.

Quick Navigation

User Menu