Skip to content
This repository has been archived by the owner on Nov 7, 2020. It is now read-only.

Malformed Json Error #48

Closed
bluntk opened this issue Feb 26, 2020 · 12 comments
Closed

Malformed Json Error #48

bluntk opened this issue Feb 26, 2020 · 12 comments

Comments

@bluntk
Copy link

bluntk commented Feb 26, 2020

Hello i am getting malformed json error after one succesfull pin. I checked rawBody response and it look like a jpeg code.
I attached a screenshot which is shows how response is.

1

@turanct
Copy link
Collaborator

turanct commented Feb 26, 2020

@bluntk thanks for reporting!

We're going to need a bit more information of how and when you get this error. Can you add some steps to reproduce? Which piece of code are you running? Which methods are you calling? Thanks

@bluntk
Copy link
Author

bluntk commented Feb 26, 2020

Of course.
First of all i call your class without any problem.
`$client = new Pinterest\Http\BuzzClient();

$auth = Pinterest\Authentication::onlyAccessToken($client, $token);

$api = new Pinterest\Api($auth);

$boards = $api->getUserBoards();

$board = $boards->body->data;

$boardId = $board[0]->id;`

Then i call image file and transform it to base64

`$base64 = base64_encode($data);

        $image = Pinterest\Image::base64($base64);

        $pinDescription = $title . ' ' . $tags;

        $response = $api->createPin($boardId, $pinDescription, $image, $pin_link);

        if (!$response->ok()) {
            echo $response->getError() . PHP_EOL;
            continue;
        }

        $pinResult = $response->result();`

and after 1 succesfull pin result is like screenshot i uploaded for this issue.

Thank you for reply

@hansott
Copy link
Owner

hansott commented Feb 27, 2020

Hi @bluntk Can you post the stacktrace of the exception you're getting? (Make sure to remove any personal details)

@bluntk
Copy link
Author

bluntk commented Feb 27, 2020

Fatal error: Uncaught Pinterest\Http\Exceptions\MalformedJson in /var/www/html/pinterest/app/classes/vendor/hansott/pinterest-php/src/Pinterest/Http/Response.php:152 Stack trace: #0 /var/www/html/pinterest/app/classes/vendor/hansott/pinterest-php/src/Pinterest/Http/Response.php(83): Pinterest\Http\Response->parseJson('\x1F\x8B\x08\x00\x00\x00\x00\x00\x04\x03\xAAVJI,...') #1 /var/www/html/pinterest/app/classes/vendor/hansott/pinterest-php/src/Pinterest/Http/BuzzClient.php(88): Pinterest\Http\Response->__construct(Object(Pinterest\Http\Request), 201, '\x1F\x8B\x08\x00\x00\x00\x00\x00\x04\x03\xAAVJI,...', Array) #2 /var/www/html/pinterest/app/classes/vendor/hansott/pinterest-php/src/Pinterest/Http/BuzzClient.php(133): Pinterest\Http\BuzzClient::convertResponse(Object(Pinterest\Http\Request), Object(Buzz\Message\Response)) #3 /var/www/html/pinterest/app/classes/vendor/hansott/pinterest-php/src/Pinterest/Authentication.php(255): Pinterest\Http\BuzzClient->execute(Object(Pinterest\Http\Request)) #4 /var/www/html/pinterest/app/c in /var/www/html/pinterest/app/classes/vendor/hansott/pinterest-php/src/Pinterest/Http/Response.php on line 152

@hansott
Copy link
Owner

hansott commented Feb 27, 2020

I'm able to reproduce!

@bluntk
Copy link
Author

bluntk commented Feb 27, 2020

Glad to hear that. I heard many other people having this error. Maybe pinterest changed something in their backend.

@hansott
Copy link
Owner

hansott commented Feb 27, 2020

They seem to return some funky stuff if reach the rate limit... You will now receive a rate limited exception instead of a malformed JSON exception ;)

@hansott
Copy link
Owner

hansott commented Feb 27, 2020

@bluntk
Copy link
Author

bluntk commented Feb 27, 2020

I dont think it is about rate limit because i have 1000 rate limit per hour. I will try and let you know if it is still exists

@bluntk
Copy link
Author

bluntk commented Feb 27, 2020

I downloaded last patch and replaced old one still got the same error.

Some people say it is about set xmlhttp = server.Createobject("Msxml2.ServerXMLHTTP.6.0") on windows.

@hansott
Copy link
Owner

hansott commented Feb 27, 2020

I have no clue why they send that weird stuff. Probably something to do with their backend I'm afraid (like you say)...

Maybe you can try contacting Pinterest? https://developers.pinterest.com/support/contact/

My test application doesn't have 1000 API calls... I can't test properly with 10 calls/hour. 😢

About the XML part, I'm a mac user :)

@bluntk
Copy link
Author

bluntk commented Feb 27, 2020

And i am linux :/ I can give you token if you want to try with more rate limit. Send me your email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants