Code Monkey home page Code Monkey logo

Comments (16)

hansott avatar hansott commented on June 10, 2024

Hi @aammadullah! Thanks for submitting your issue. I'll take a look!

from pinterest-php.

aammadullah avatar aammadullah commented on June 10, 2024

Thanks for response, But I think this issue is from pinterest side because I have checked it through curl request and when I am changing code to an access token I am getting this response { "status": 403, "message": "Forbidden" }
So may be you can better know about this, So please have a look and inform me about the issue what you have understood so far.
Thanks!

from pinterest-php.

hansott avatar hansott commented on June 10, 2024

I've used the following script and did not encounter your error...

<?php

require_once 'vendor/autoload.php';

date_default_timezone_set('UTC');

use Pinterest\App\Scope;

$client = new \Pinterest\Http\BuzzClient();
$appId = 'myAppId';
$appSecret = 'myAppSecret';
$auth = new \Pinterest\Authentication($client, $appId, $appSecret);

$url = $auth->getAuthenticationUrl(
    'https://localhost',
    array(
        Scope::READ_PUBLIC,
        Scope::WRITE_PUBLIC,
        Scope::READ_RELATIONSHIPS,
        Scope::WRITE_RELATIONSHIPS,
    ),
    'random-state'
);

/**
 * 1. echo $url;
 * 2. echo $auth->requestAccessToken('code');
 * 3. $auth = \Pinterest\Authentication::onlyAccessToken(
 *       $client,
 *       'accessToken'
 *    );
 *
 * $api = new \Pinterest\Api($auth);
 * $response = $api->getUserFollowers();
 * var_dump($response);
 */

That seems to work fine... I think you're missing something.

Could you copy / paste the code that you're using? Make sure to remove your app ID, app secret and access tokens.

from pinterest-php.

aammadullah avatar aammadullah commented on June 10, 2024

Did the code changed to an access token ?

from pinterest-php.

hansott avatar hansott commented on June 10, 2024

I'm not sure what you mean? Could you copy / paste the code that you're using, so I can take a look?

from pinterest-php.

aammadullah avatar aammadullah commented on June 10, 2024
getAuthenticationUrl( 'https://socialwebtool.com/pinterestApi/index.php', array( Scope::READ_PUBLIC, Scope::WRITE_PUBLIC, Scope::READ_RELATIONSHIPS, Scope::WRITE_RELATIONSHIPS, ), 'random-stringeri' ); if(isset($_GET['code'])){ $code = $_GET['code']; $token = $auth->requestAccessToken($code); }else { ``` header('Location: ' . $url); ``` }

from pinterest-php.

aammadullah avatar aammadullah commented on June 10, 2024

https://socialwebtool.com/pinterestApi/index.php?state=random-stringeri&code=dbedc77ef227de8d

Above is the link and below is the error

Fatal error: Uncaught Pinterest\Api\Exceptions\TokenMissing in /home/socialwe/public_html/pinterestApi/vendor/hansott/pinterest-php/src/Pinterest/Authentication.php:222 Stack trace: #0 /home/socialwe/public_html/pinterestApi/index.php(29): Pinterest\Authentication->requestAccessToken('dbedc77ef227de8...') #1 {main} thrown in /home/socialwe/public_html/pinterestApi/vendor/hansott/pinterest-php/src/Pinterest/Authentication.php on line 222

I will be very thankfull if you solved this

from pinterest-php.

hansott avatar hansott commented on June 10, 2024

You're code looks good. Can you copy / paste a var_dump of $response in https://github.com/hansott/pinterest-php/blob/master/src/Pinterest/Authentication.php#L216?

from pinterest-php.

aammadullah avatar aammadullah commented on June 10, 2024

object(Pinterest\Http\Response)#10 (6) { ["body"]=> object(stdClass)#11 (2) { ["status"]=> int(403) ["message"]=> string(9) "Forbidden" } ["statusCode":"Pinterest\Http\Response":private]=> int(403) ["rawBody":"Pinterest\Http\Response":private]=> string(41) "{ "status": 403, "message": "Forbidden" }" ["headers":"Pinterest\Http\Response":private]=> array(7) { ["Age"]=> string(1) "0" ["Cache-Control"]=> string(7) "private" ["Content-Type"]=> string(37) "application/javascript; charset=utf-8" ["X-Pinterest-RID"]=> string(12) "187749399847" ["Content-Length"]=> string(2) "41" ["Date"]=> string(29) "Fri, 14 Oct 2016 17:56:06 GMT" ["Connection"]=> string(10) "keep-alive" } ["result":"Pinterest\Http\Response":private]=> NULL ["request":"Pinterest\Http\Response":private]=> object(Pinterest\Http\Request)#7 (4) { ["method":"Pinterest\Http\Request":private]=> string(4) "POST" ["endpoint":"Pinterest\Http\Request":private]=> string(40) "https://api.pinterest.com/v1/oauth/token" ["params":"Pinterest\Http\Request":private]=> array(4) { ["grant_type"]=> string(18) "authorization_code" ["client_id"]=> string(19) "clientId" ["client_secret"]=> string(64) "clientSecret" ["code"]=> string(16) "code" } ["headers":"Pinterest\Http\Request":private]=> array(0) { } } }

from pinterest-php.

hansott avatar hansott commented on June 10, 2024

I've deleted your app ID and app secret from your comment.

from pinterest-php.

aammadullah avatar aammadullah commented on June 10, 2024

Ok thanks! I have forgotten

from pinterest-php.

hansott avatar hansott commented on June 10, 2024

Can you try it locally (not on server)? Use https://localhost as callback url. I think Pinterest blocks some IP addresses. Is your app hosted on Amazon?

from pinterest-php.

aammadullah avatar aammadullah commented on June 10, 2024

no its hosted on hostblast.net
I am trying on localhost thanks for the advice. I will be back

from pinterest-php.

aammadullah avatar aammadullah commented on June 10, 2024

What can I do then If they blocked my server IP ?

from pinterest-php.

hansott avatar hansott commented on June 10, 2024

You can contact them at https://developers.pinterest.com/support/contact.

I really think they are blocking your IP address, because you're code seems fine and it works for me. Thus you're error is probably not related to the library.

If you have any other questions, feel free the re-open.

Good luck!

from pinterest-php.

aammadullah avatar aammadullah commented on June 10, 2024

Thanks bro , Its working on localhost, And thanks for the advice brother

from pinterest-php.

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.