Post: PSN API Wrappers (Golang/PHP)
04-16-2016, 01:27 AM #1
Tustin
Balls of Steel
(adsbygoogle = window.adsbygoogle || []).push({}); This thread will now be dedicated to both my PHP and Golang PSN API wrapper libraries. I still work on both (although more-so the golang one atm because it still needs features) so I don't want to manage two different threads.

PHP

I wrote this PHP wrapper for the PSN API. Some people had asked for the code of the PSN Lookup on my website, but I wanted to clean it up before sharing it. This can do that, and (eventually) more. As of right now it just has authentication but I have created classes for friends, messaging, activity and trophies but I need to clean them up a bit before committing it to the repo. It's pretty clean if I do say so myself and it works very well. Feel free to check out the code and star/watch it if you're interested in updates.

You must login or register to view this content.

If you want to use it, the readme has proper documentation of what is available so far.



Go

Still a WIP but this will soon become up to speed with the PHP version. No docs atm but when I'm done, they will be made.

You must login or register to view this content.

Last edited by Tustin ; 05-21-2017 at 05:25 AM.

The following 10 users say thank you to Tustin for this useful post:

Father Luckeyy, IcarusXSEC, Kryptus, Norway-_-1999, Octolus, OgKillaBee187, Passion, THΞSPIKYBROHD, tyman1294
04-16-2016, 01:38 AM #2
Does PSN not have a image size limit?
You should add a size limit and add a suppressor to file_get_contents($URL);
to prevent errors in case the file size is bigger than expected.

Also if people where to use the UploadPicture function
you would probably be able to knock it down just by
requesting big files. (DOS Vuln)

    
//Uploads an image for profile picture (still a WIP)
public function UploadPicture($URL)
{
$bytes = file_get_contents($URL);
$request = '--abcdefghijklmnopqrstuvwxyz
Content-Disposition: form-data; name="source"; filename=image.png
Content-Type: image/png
' . $bytes . '
--abcdefghijklmnopqrstuvwxyz--';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, PROFILE_PIC_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$headers = array(
'Authorization: Bearer ' . $this->oauth,
'Content-Type: multipart/form-data; boundary=abcdefghijklmnopqrstuvwxyz'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$output = curl_exec($ch);
curl_close($ch);
$data = json_decode($output, false);
return $data;
}
Last edited by D4tabase ; 04-16-2016 at 01:42 AM.
04-16-2016, 01:50 AM #3
Tustin
Balls of Steel
Originally posted by D4tabase View Post
Does PSN not have a image size limit?
You should add a size limit and add a suppressor to file_get_contents($URL);
to prevent errors in case the file size is bigger than expected.

Also if people where to use the UploadPicture function
you would probably be able to knock it down just by
requesting big files. (DOS Vuln)

    
//Uploads an image for profile picture (still a WIP)
public function UploadPicture($URL)
{
$bytes = file_get_contents($URL);
$request = '--abcdefghijklmnopqrstuvwxyz
Content-Disposition: form-data; name="source"; filename=image.png
Content-Type: image/png
' . $bytes . '
--abcdefghijklmnopqrstuvwxyz--';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, PROFILE_PIC_URL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$headers = array(
'Authorization: Bearer ' . $this->oauth,
'Content-Type: multipart/form-data; boundary=abcdefghijklmnopqrstuvwxyz'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$output = curl_exec($ch);
curl_close($ch);
$data = json_decode($output, false);
return $data;
}

Yeah, I should've not even included that function. Once I got it working I just moved on to something else so I didn't really bother with additional checks. You could probably use different file formats as well, but I only tried png. The image is also restricted to 440x440 but that's about all I know about it.
04-16-2016, 09:25 PM #4
Passion
League Champion
Originally posted by Tustin View Post
I wrote this PHP library/interface whatever you want to call it for the PSN API. Some people had asked for the code of the PSN Lookup on my website, but I wanted to clean it up before sharing it. This can do that, and (eventually) more. As of right now it just has authentication but I have created classes for friends, messaging, activity and trophies but I need to clean them up a bit before committing it to the repo. It's pretty clean if I do say so myself and it works very well. Feel free to check out the code and star/watch it if you're interested in updates.

You must login or register to view this content.

If you want to use it, the readme has proper documentation of what is available so far.


Awesome share, so this can be used for a PSN Bomber?
04-16-2016, 09:26 PM #5
Tustin
Balls of Steel
Originally posted by Passion View Post
Awesome share, so this can be used for a PSN Bomber?

Yeah, but that's assuming I decided to release the messaging class I made. I might not just due to it being abused for something like that :p. Of course someone could always figure out how messages are sent; it's not too hard.
04-16-2016, 09:28 PM #6
Passion
League Champion
Originally posted by Tustin View Post
Yeah, but that's assuming I decided to release the messaging class I made. I might not just due to it being abused for something like that :p. Of course someone could always figure out how messages are sent; it's not too hard.


Should probably keep it to yourself as of now, since Octolus has a PSN Bomber service and this could destroy his sales
04-17-2016, 05:09 PM #7
Octolus
I defeated!
Originally posted by Passion View Post
Should probably keep it to yourself as of now, since Octolus has a PSN Bomber service and this could destroy his sales


My servers got blocked so yeah can't make it worse than it is. And mine is not written in PHP, it's in Python. Making a bomber in PHP, would be way too resource intensive (due making many requests).

Anyway, great work. Looks easy to use Smile
04-18-2016, 08:13 PM #8
Tustin
Balls of Steel
I've updated the repo with messaging, friends and trophies. I'll work on the documentation later to show how you use them Tustin.
You must login or register to view this content.
05-02-2016, 07:38 PM #9
OsaMasw
Save Point
how to get user trophy information, not my info, I want to pull another user info
05-02-2016, 09:11 PM #10
Tustin
Balls of Steel
Originally posted by OsaMasw View Post
how to get user trophy information, not my info, I want to pull another user info

I was going to add that but the only way I found to view user trophy info was comparing trophies. I'll look into it a bit more when I have time and see about adding a way to get that info.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo