Reputation: 11
I have fetched my existing bords on pinterst and got the information like Board Id,Board Name and Board URL. However I want to post a Picture with Link and Description CURL code gives me error "Authorization failed"
my code is:
$url_pin = 'https://api.pinterest.com/v1/pins/?board=' . $userName . '/' . $board_name . '&note=' . $post['scheduled_text_message'] . '&link=' . $link . '&image_url=https://www.postsharing.com/img/PostSharing.png';
$ch_pin = curl_init();
curl_setopt($ch_pin, CURLOPT_URL, $url_pin);
curl_setopt($ch_pin, CURLOPT_POST, 1);
curl_setopt($ch_pin, CURLOPT_RETURNTRANSFER, true);
$server_pin = curl_exec($ch_pin);
curl_close($ch_pin);
$decoded_pin = json_decode($server_pin, true);
i am getting json_decoded result like this:-
Array
(
[status] => failure
[code] => 3
[host] => devplatform-devapi-prod-3c889f83
[generated_at] => Mon, 28 Dec 2015 09:04:02 +0000
[message] => Authorization failed.
[data] =>
)
Please anyone help me to fix this issue. Thanks
Upvotes: 1
Views: 1633
Reputation: 11106
You can't just cobble something to a board w/o valid authentication. And, userid and password aren't sufficient at all.
You need to register your App, with which you want to post to your board, at Pinterest Developers at https://developers.pinterest.com/apps/
Having an App key and secret, you may then get yourself an oAuth access token, read http://oauth.net/ or https://developers.pinterest.com/docs/api/overview/
Once having a valid oAuth token, add this to your URL above:
$url_pin = 'https://api.pinterest.com/v1/pins/?board=' . $userName . '/' . $board_name . '&note=' . $post['scheduled_text_message'] . '&link=' . $link . '&image_url=https://www.postsharing.com/img/PostSharing.png&access_token=' + $token;
Upvotes: 1