Comments (29)
@capripio one more solution. I think it will solve problems with permissions. In file Api/Request.php in constructor change cookieJar for curl:
/**
* @param HttpInterface $http
* @param string|null $userAgent
*/
public function __construct(HttpInterface $http, $userAgent = null)
{
$this->http = $http;
if ($userAgent !== null) {
$this->userAgent = $userAgent;
}
// $this->cookieJar = self::COOKIE_NAME; <--- before
$this->cookieJar = tempnam(sys_get_temp_dir(), self::COOKIE_NAME); // <-- after
}
from php-pinterest-bot.
Hi, I've checked now, everything seems to be working with the latest version, can you show your code?
What is output of print_r($bot->getLastError());
?
from php-pinterest-bot.
$bot = PinterestBot::create();
$boards = $bot->boards->forUser('USER GOES HERE');
$bot->login('[email protected]', 'passwordGoesHere');
$bot->pins->create($book->img_url, $boards[0]['id'], $desc);
from php-pinterest-bot.
I've used it with laravel.
from php-pinterest-bot.
Very strange. I've just checked it in Laravel.
As a quick solution you may comment 34 line in /Api/Providers/ProviderLoginCheckWrapper.php and try. I'll continue research for bugs.
from php-pinterest-bot.
yes, I did try that, but it doesn't make pin. Let me retry again and update, I've missed something.
from php-pinterest-bot.
So I dig deeper in login method, here is the response I get at line 109 in Pinners.php
Might help you
array:5 [▼
"request_identifier" => "224645968114"
"resource_data_cache" => []
"resource" => array:2 [▼
"name" => "UserSessionResource"
"options" => array:3 [▼
"username_or_email" => "EMAIL HERE"
"bookmarks" => array:1 [▼
0 => "-end-"
]
"password" => "PASSWORD HERE"
]
]
"client_context" => array:39 [▼
"origin" => "https://nl.pinterest.com"
"unauth_id" => "89e7c9d2b449458cb3f2ed1bacfa280a"
"is_retina" => false
"user_agent_platform" => "other"
"sterling_admin_mode_view_as" => null
"is_authenticated" => true
"allow_image_prioritization" => true
"browser_locale" => "en-US"
"deep_link_action" => null
"triggerable_experiments" => array:201 [▶]
"visible_url" => "/login/"
"is_tablet_agent" => false
"utm_campaign" => null
"browser_type" => 4
"deep_link" => ""
"site_type" => 0
"from_open_in_app_click" => null
"invite_code" => null
"use_react" => true
"locale" => "en-US"
"utm_medium" => null
"giftwrap_holdout" => false
"app_version" => "d6936eb"
"site_const" => array:5 [▶]
"real_ip" => "39.48.31.185"
"user_agent_is_ios_9_2_or_above" => false
"active_experiments" => array:2 [▼
"related_pins_closeup" => "enabled"
"render_using_react_3" => "enabled"
]
"user" => array:39 [▼
"is_employee" => false
"username" => "USERNAME HERE"
"last_name" => ""
"domain_verified" => false
"nags" => []
"image_medium_url" => "https://s-media-cache-ak0.pinimg.com/avatars/bookler4288_1461317847_75.jpg"
"has_password" => true
"full_name" => "FULL NAME HERE"
"image_small_url" => "https://s-media-cache-ak0.pinimg.com/avatars/bookler4288_1461317847_30.jpg"
"gplus_url" => null
"id" => "202310345669271373"
"is_write_banned" => false
"first_name" => "FULL NAME HERE"
"domain_url" => "URL HERE"
"has_seen_notifications" => false
"personalize_from_offsite_browsing" => true
"facebook_timeline_enabled" => false
"personalize_nux_from_offsite_browsing" => false
"connected_to_rakuten" => false
"facebook_id" => ""
"connected_to_google" => false
"is_partner" => false
"type" => "user"
"email" => "EMAIL HERE"
"image_large_url" => "https://s-media-cache-ak0.pinimg.com/avatars/bookler4288_1461317847_140.jpg"
"connected_to_yahoo" => false
"verified_identity" => []
"twitter_url" => null
"facebook_url" => null
"twitter_publish_enabled" => false
"ads_customize_from_conversion" => true
"facebook_publish_stream_enabled" => false
"connected_to_microsoft" => false
"gender" => "female"
"created_at" => "Fri, 22 Apr 2016 09:35:40 +0000"
"login_state" => 1
"website_url" => "WEBSITE LINK HERE"
"country" => "PK"
"extension_access_token" => null
]
"deep_link_default" => ""
"http_referrer" => "https://nl.pinterest.com/"
"is_mobile_agent" => false
"is_internal_ip" => false
"language" => "en"
"is_sterling_on_steroids" => false
"referrer" => null
"user_agent_can_use_native_app" => false
"browser_name" => "Firefox"
"country" => "PK"
"error_template_path" => "templates/error.nunjucks"
]
"resource_response" => array:2 [▼
"data" => array:1 [▼
"token_type" => "bearer"
]
"error" => null
]
]
from php-pinterest-bot.
Yes, logged in successfully, let's debug. Next on line 115 place var_dump($this->request->isLoggedIn());
And in ProviderLoginCheckWrapper on line 53 var_dump($methodRequiresLogin && !$isLoggedIn);
from php-pinterest-bot.
Line 115:
Request {#172 ▼
#userAgent: "Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0"
#http: CurlAdapter {#178 ▼
-curl: Unknown resource @243
}
#loggedIn: null
#cookieJar: "pinterest_cookie"
#options: array:11 [▼
10018 => "Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0"
19913 => 1
64 => 0
52 => 1
10102 => "gzip,deflate"
10023 => array:11 [▼
0 => "Accept: application/json, text/javascript, /; q=0.01"
1 => "Accept-Language: en-US,en;q=0.5"
2 => "DNT: 1"
3 => "Host: nl.pinterest.com"
4 => "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"
5 => "X-Pinterest-AppState: active"
6 => "X-NEW-APP: 1"
7 => "X-APP-VERSION: 04cf8cc"
8 => "X-Requested-With: XMLHttpRequest"
9 => "X-CSRFToken: 1234"
10 => "Cookie: csrftoken=1234;"
]
10016 => "https://nl.pinterest.com/"
10031 => "pinterest_cookie"
10082 => "pinterest_cookie"
47 => 1
10015 => "source_url=%2Flogin%2F&data=%7B%22options%22%3A%7B%22username_or_email%22%3A%22social%40bookler.xyz%22%2C%22password%22%3A%22windows%22%7D%2C%22context%22%3A%7B%7D%7D"
]
+csrfToken: null
#requestHeaders: array:9 [▼
0 => "Accept: application/json, text/javascript, /; q=0.01"
1 => "Accept-Language: en-US,en;q=0.5"
2 => "DNT: 1"
3 => "Host: nl.pinterest.com"
4 => "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"
5 => "X-Pinterest-AppState: active"
6 => "X-NEW-APP: 1"
7 => "X-APP-VERSION: 04cf8cc"
8 => "X-Requested-With: XMLHttpRequest"
]
}
from php-pinterest-bot.
53 returns false, which cause exception of auth
from php-pinterest-bot.
I see, i think it is because of rights. When logged in request is made, it saves cookies on disk to parse and to get token from it. In Request.php
on 185 line. I think script has no rights to create files, so no token has been parsed.
It's my fault, I should raise an exception here. Please check rights on your directory.
from php-pinterest-bot.
Script saves cookies in it's root path in pinterest_cookie
file.
from php-pinterest-bot.
are you talking about following function? Its doesn't seems to called, i can't debug it here. and I am using Windows I don't think any issue with permission?
public static function createQuery(array $data = [], $sourceUrl = '/', $bookmarks = [])
{
$request = self::createRequestData($data, $sourceUrl, $bookmarks);
return UrlHelper::buildRequestString($request);
}
from php-pinterest-bot.
No, Api\Request.php
line 185:
public function setLoggedIn()
{
$this->csrfToken = CsrfHelper::getTokenFromFile($this->cookieJar); // <--- parsing token from file
if (!empty($this->csrfToken)) {
$this->loggedIn = true;
}
return $this;
}
I think the problem is here. No token has been parsed.
from php-pinterest-bot.
well this code intersect with in line no. 158.
from php-pinterest-bot.
public function setLoggedIn()
{
$this->csrfToken = CsrfHelper::getTokenFromFile($this->cookieJar);
if (!empty($this->csrfToken)) {
$this->loggedIn = true;
}
return $this;
}
from php-pinterest-bot.
Yes, here. I think $this->csrfToken
is empty in your case.
from php-pinterest-bot.
yes it does.
from php-pinterest-bot.
try to change directory permissions
from php-pinterest-bot.
can you tell me when your code store file I might debug it out!
from php-pinterest-bot.
If you are using Laravel, it will be in public folder
from php-pinterest-bot.
hmm that's strange I've provided right too all users still unable to do login.
from php-pinterest-bot.
however thanks for help, since its seems issue on my side, I must have miss something. I will close this bug and debug whole thing in morning.
Have a good day!
Good Night.
from php-pinterest-bot.
Ok, good luck to you! May be try manually create this file empty in laravels public folder.
from php-pinterest-bot.
ok let me try it now!
from php-pinterest-bot.
it's worked! I guess I need to learn about 2 new functions 👍
from php-pinterest-bot.
Oh, that's great!)
from php-pinterest-bot.
Thanks! finally I can sleep now :D you know what I mean! Good Night and Thanks again!
from php-pinterest-bot.
Good night) I've published a new release of library with this fix. Update tomorrow, and there will be no need to change library source.
from php-pinterest-bot.
Related Issues (20)
- Create APP and Get Token
- Problem to create a new pin HOT 6
- [Invalid email.] When Registering Pinterest
- Здравствуйте.
- Registration error: Invalid parameters. HOT 2
- account banned HOT 1
- how can be scheduled images to go live at a later date on pinterest using api in php? HOT 1
- Keywords recommend not working anymore HOT 1
- Can we create a pin with access_token?
- Domain Spam or Blocked Check?
- Error when create acc
- is it possible to add multiple keywords ? HOT 4
- Pinterest rate limits HOT 2
- Get Boards Return Empty
- Observing the PhP Fatal Error again with the v5.9.1 HOT 9
- Can you please help me to use the edit command ?
- Your requirements could not be resolved to an installable set of packages.
- Autoloader issue
- Login method not working HOT 9
- Is this project dead? Cannot connect Pinterest Account.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-pinterest-bot.