Code Monkey home page Code Monkey logo

psn-php's Introduction

PSN-PHP Wrapper

A PHP wrapper for the PlayStation API.

GitHub stars GitHub license

Getting Started

Pull in the project with composer: composer require tustin/psn-php

Documentation

Please visit the psn-php documentation page to see how to use this library.

Disclaimer

This project was not intended to be used for spam, abuse, or anything of the sort. Any use of this project for those purposes is not endorsed. Please keep this in mind when creating applications using this API wrapper.

psn-php's People

Contributors

acleon avatar barantr90 avatar bozzit avatar fleyx avatar jbdabes avatar jemixs avatar krisseck avatar martinbean avatar mrcrazylee avatar nalorokk avatar octolus avatar ragowit avatar spahost avatar steve228uk avatar tustin avatar vicegold avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

psn-php's Issues

problems with installation

hi I wanted to try your psn API
but when I start the testfile I always get an internal error 500.

These are my installation steps:
I tried to install it on my Ubuntu 16.0 System

first, i installed composer.
After that, I opened terminal and jumping in my /var/www/html folder
then I typed: composer require tustin/psn-php
and got the follow messages

tim@tim-ThinkPad-T530:/var/www/html$ composer require tustin/psn-php
Using version ^1.1 for tustin/psn-php
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals

  • Installing tustin/psn-php (v1.1.0): Loading from cache
    Writing lock file
    Generating autoload files

now i got the follow files:

composer.json composer.lock vendor

i created than an index.php which looks like this:

GetError()); } $tokens = $account->GetTokens(); ?>

When I am now open the browser and go to my localhost address.

I can see my echo call Authentification, but nothing else.
When I check the website with the tools of the Firefox browser I can see an error,
localhost/:1 GET http://localhost/ 500 (Internal Server Error).

So do you have any advice for me what I doing wrong?

this what the composer.json file loooks like:
{
"require": {
"tustin/psn-php": "^1.1"
}
}

Suggestion: Getting Voice Recording How-To

I've edited this far too much to throw up a Git Repo and do a pull request at this point (my code is majorly in flux anyway).

But I did figure out how to get the voice messages.

A friend did one and it's just an MP3 file.

Instead of image-data-0, use voice-data-0 for the Content Key.

Then use audio/mpeg as the Content-Type header.

I modified it like this: http://pastebin.com/nv2PVC94

Respond to a conversation?

How would we do this?

I'm creating a tool to allow you sign into my site, then it will show all messages. Allow you to moderate them, also reply.. However I haven't figured out a way to respond to a existing conversation..

Game(s) missing from GetMyTrophies

Hi,

I've got your code working, but I noticed that at least one game is missing.

If I look on https://my.playstation.com/ I can see the trophies for this game. Also if I call the trophies by game they show up. Any thoughts on why this would be?

This code is missing the game (the game id is NPWR08142_00 if that helps):

$trophy = new \PSN\Trophy($tokens); $my_trophies = $trophy->GetMyTrophies(); var_dump($my_trophies);

This code works when I pass the game id:

$trophy = new \PSN\Trophy($tokens); $trophiesList = $trophy->GetGameTrophies($gameId); $trophiesList = $trophiesList->trophies;

Function to get GroupID by name

Not sure if the following would have any value to the project.

New to contributing to Public Projects and not sure I will be contributing allot more so if there is another way I should be doing this let me know.

Messaging.php

public function GetGroupIdByName($sGroupName)
    {
       $oAllgroups = $this->GetAll();

       $sThreadId = null;

       foreach( $oAllgroups->threads as $iKey =>  $aGroupDetails)
       {
          if ($aGroupDetails->threadNameDetail->threadName == trim($sGroupName))
          {
             $sThreadId = $aGroupDetails->threadId;
             break;
          }

       }
       return $sThreadId;
}

Usage:

$messaging = new \PSN\Messaging($tokens);

$sMsgGroupID = $messaging->GetGroupIdByName('Group Name');

$messaging->TextMessageGroup($sMsgGroupID, 'Test Message From PSN PHP');

Auth not work

Hi, since few days when try to connect an account got this response : First parameter must either be an object or the name of an existing class on line 155

Line 155 : if (property_exists($data, "error")){
$this->last_error = $response["body"];
return false;
}

Unexpected character in input.

I setup everything as you said, but when I went to my site to check if all was working I got an error.
Since I'm not familiar with PHP (only interested in the PSN API) I don't really know what is happening here.

The only thing I changed was my emailadress and the password. Unless some characters cannot be included in the emailadress, I don't really know what could be causing this issue.

I attached the full error as an image.
2016-07-14_11h21_06

Playstation 4 Game Statistics

Hi,

First of all thank you for this repo. I was wondering if there's a way to get game stats using from playstation 4 to a website (just like in Xbox). Would this be possible? if so please do let me know how thank you.

Best,
Vincent

Response headers output

Hey there,

I'm now running this code on a separate project from the one I mentioned in Issue #5 , and I'm seeing this output when I try to use it via command line:

  • Hostname auth.api.sonyentertainmentnetwork.com was found in DNS cache
  • Trying 104.100.130.158...
  • Connected to auth.api.sonyentertainmentnetwork.com (104.100.130.158) port 443 (#0)
  • TLS 1.2 connection using TLS_RSA_WITH_AES_256_CBC_SHA256
  • Server certificate: auth.api.sonyentertainmentnetwork.com
  • Server certificate: COMODO SHA-256 Domain Validation Secure Server CA
  • Server certificate: AddTrust External CA Root
    GET /2.0/oauth/authorize?state=06d7AuZpOmJAwYYOWmVU63OMY&duid=0000000d000400808F4B3AA3301B4945B2E3636E38C0DDFC&app_context=inapp_ios&client_id=b7cbf451-6bb6-4a5a-8913-71e61f462787&scope=capone%3Areport_submission%2Cpsn%3Asceapp%2Cuser%3Aaccount.get%2Cuser%3Aaccount.settings.privacy.get%2Cuser%3Aaccount.settings.privacy.update%2Cuser%3Aaccount.realName.get%2Cuser%3Aaccount.realName.update%2Ckamaji%3Aget_account_hash%2Ckamaji%3Augc%3Adistributor%2Coauth%3Amanage_device_usercodes&response_type=code HTTP/1.1
    Host: auth.api.sonyentertainmentnetwork.com
    Accept: /
    Cookie: npsso=Fxn3PO3GgsgP1fxcaLyfyt2MvV1543P0J65Svjjmih4PjH8ugOk086GdKUJ3E8kZ

< HTTP/1.1 302 Moved Temporarily
< Location: https://auth.api.sonyentertainmentnetwork.com/mobile-success.jsp?targetUrl=com.playstation.mobilemessenger%3A%2F%2Fredirect%3Fcode%3DGw71y6%26state%3D06d7AuZpOmJAwYYOWmVU63OMY&close=false&timestamp=1472767540881
< Server: Apache
< p3p: CP="This site does not have a P3P policy."
< x-wily-info: Clear guid=E7C93E660AD3C1A6371BEF0F2DF4E5EA
< x-wily-servlet: Encrypt1 hR/KG2GOR16aRfvv3/q1AYV2vat6ytTFs7un7pSEpvnQOZ4fhaUVHDqwyKhmMdyc6AvmzDhSUcixgr6qN2pl2KxVY0S9jvPiL4YIx7Ts+VKxBFby1NT6vPSc39Y1GE+CTbxiiKORkyZzKN4w+wcMsHbX/yeSzPjQqy4o2hvP9iqn9b3L9iKxAY2Jzmoc7dAg
< Pragma: no-cache
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Cache-Control: no-cache
< Cache-Control: no-store
< X-NP-GRANT-CODE: Gw71y6
< Content-Language: en-US
< Content-Length: 0
< Content-Type: text/plain; charset=UTF-8
< Date: Thu, 01 Sep 2016 22:05:40 GMT
< Connection: keep-alive
< Set-Cookie: JSESSIONID=CD5BC225B7B942C88DB177453D48C2E7.lvp-p2-npversat29-4509; path=/; HttpOnly; secure
<

  • Connection #0 to host auth.api.sonyentertainmentnetwork.com left intact

Is this some output left from debugging the code, or is this necessary to be shown every time we make a request?

Thanks,
Dan

Tokens

I don't understand exactly how to use:
$new_tokens = Auth::GrabNewTokens($tokens['refresh']);

I would love to save my accounts, as i'm making a api to get users data. But accounts keep dropping like flies! I'm assuming the GrabNewTokens method would save the accounts life span.

Thanks!

How can I secure login to PSN

Hello,

I have a web site with a button like 'link your psn account'.
For now I write my email and password in my code block then login, get datas etc. but normally someone who visit my site does not want to write email and password in my form right? Is there a way to direct a user to PSN web site then login and redirect my web site?

Auth ok ! :)

Thank you for your work ! Are you still working on it?

Messy code problem

Hi, Thanks a lot for your work. I tried this api and I checked my account info like this:

$user = new \PSN\User($tokens);
$me = $user->Me();
var_dump($me);

It gives quite lots of information, and I checked most of the info works correctly, but in [aboutMe] part, there's messy code problem like this:
["aboutMe"]=> string(74) "銆岋紛锛娿€嶅皬澶勬垚灏卞ぇ浜嬨€岋紛锛娿€岹reatness From Small Beginnings."
the correct one should be:
["aboutMe"]=> string(stringnum) "小处成就大事,Greatness From Small Beginnings." It's Chinese + English. May this be fixed?
By the way, I'm new to PHP, is there any convenient way to get specific information? For example I may just want to get my ID and Trophy numbers?
Thanks again.

Add support for Composer

Repository should have a composer.json, and use either the PSR-0 or PSR-4 autoloading standard.

Psn URLs

Is there a way to learn all psn urls like showing mutual friends?

I already checked on my mobile app and I can see me and my friend mutual friends also GetInfo function show me mutual friends count.

Other User's Trophies

Hello. Thanks your awesome project.
I could get my trophies using $trophy->GetMyTrophies();

But,
How can I get other user's trophies?
is it impossible now?

GrabNewTokens Function enhancement

I propose that Instead of returning false, returning the error_code and error_description so one has an idea of why it failed.

            if (property_exists($data, "error")){
              throw new AuthException(sprintf('[%s]: %s', $data->error_code,
                                                          $data->error_description));
            }

Calling the Function like this:

try
{
   // Retrieve refresh token from DB or external file
   //
   $new_tokens = \PSN\Auth::GrabNewTokens('cd9a09d3-xxx-4b75-bf19-1c6eba6d05e2');
   echo 'success';
   var_dump($new_tokens);
   // Store new refresh token to DB or external file
   // Do you API calls
}
catch (\PSN\AuthException $e)
{
   print $e->GetError();
   // [4159]: Invalid refresh token
   exit;
}

I'll be submitting a merge request if you think this change is worth while.

Game Detail Request

First, This API is fantastic, Awesome work. Really appreciate your work.

Small request, if we have the gameID (ie NPWR07466_00 = Rocket League), Is there another endpoint to get more indepth information about the game then just trophies?

This would be extremely helpful

-edit I know of this url https://store.playstation.com/store/api/chihiro/00_09_000/container/US/en/999/UP2002-CUSA01163_00-ROCKETLEAGUENA01 but the gameID seems to be regional and not sure how to convert the two.

Thanks again

Export Messages To CSV

What would be the easiest way to create a message archive of your messages as CSV? (Sent & Received)

Thank You!

Question: client_id, client_secret, duid and state values

Hi, looking for an updated version for the gumer-psn project I found this one (great work on the updated auth code!) and I was wondering if it would be wise to change some of these values before using your code:
client_id, client_secret, duid, state

Are you using reverse engineered values for those (native Android/iOS apps, desktop web app) or can some of them be generated (for example: state and client_secret)?.
Also, why is the client_id value used in login_request different than the one used for other request: oauth, code, refresh_oauth?

Thanks in advance!.

Sending messages stopped working

Hello there,

My company hired a developer to build out an application that uses your repo to send PSN messages. It was working nicely, and then out of nowhere about 2 weeks ago it stopped functioning properly, and messages are not going out anymore. Would you have any insight into why this might have happened?

We heard that Sony may have started using a Captcha when users are logging in, and that might have messed with our account - but we haven't seen one when trying to log in using the PSN phone app or the online site.

Thanks in advance for any help you can provide,
Dan Delaney

Tokens

Hello there,

im porting this code to python but first i want to understand few things. Yesterday i was able to auth, and everything okay, but then today i get this:

{"error":"invalid_token","error_description":"Invalid token","error_code":4097,"docs":"http://docs.auth.api.ac.playstation.net/2.0/ssocookie","parameters":["captchatokenmissing"]}

I did not save the tokens in the very first login, so... Is there a way to get new token and be able to log in again?

Regards

error : invalid_np_grant

When I refresh my page, I often have this error:

{"error":"invalid_np_grant","error_description":"Failed to obtain X-NP-GRANT-CODE","error_code":20}

an idea ?
thx

Show Friends without Token error

I've seen a lot of apps in the App Store, that show the list of friends connected to the PSN (like "PSN Buddies").

I've tried to get the list with your script, but it gave me an error during the login phase (the same of the previous issue).

Is there a method to log in through playstation.com (with a popup, like google login) and then return the results to my page?

Constantly getting error 500 codes.

Hi,
Your project is really cool and interesting, but when I try to auth it with composer/manual installation, I get 500 http error codes. I assume the only dependies are cURL and a recent PHP version so I got those installed on my RasPi. Do you have any way to troubleshoot my problems? I'm not a php developer so any help would be appreciated. I do have some experience with cURL and the chrome devolper console, so maybe I can help out if you want to add new features.

Invalid token

I don't know why, but i'm getting the error "Invalid token" after being logged in.

Someone knows why?

Hidden achievements

Is it possible to get via api info (image, title and description)about hidden not received achievements?

Connect with a proxy ?

Hello,

thanks for this share, it's really awesome :p

I wanted to know if there is a way to use it with a proxy ?

Please Help I'm New

Hello, I'm new to this site and all of the coding as well. I am here looking for help on how to find information for a particular PSN account. It was an old account of mine that was hacked and I am trying to get it back. Sony support will not help me because I do not know the current email the PSN is under. If anyone can help me that would be really appreciated.

Create Group and invite

How would i go about creating a group and inviting a psn name to such group. By the way awesome project and thanks in advance!

Read single Message

Is there a possibility to read a single message and fetch f.e. the attachment like an image ?

Retrieve clean data

Hello everyone,

Can someone give me a helping hand, or tell me on which voice to turn me, I would like to retrieve messages from my community, so I do a var dump as in the doc, but I would like to put a little In shape and really recover puddles and messages, I imagine to loop?

I do not know at all to retrieve the data of the table.

Thank you !

Session time

Is there a way to understand a user logged in?
Now, every time when I send a request to Url, login function is working and get a lot of time.

Get Game Title by GameID?

First of all, thanks for Tustin to share this project!

I had get all trophies data by this project, and crawled game data from psn store. But I can't associate them, is there any way to get game title by game id(ex. NPWR07466_00)?

And another two question:
1.How to get trophies detail in other language like zh-CN or zh-TW? (I think I have solved this problem, but I still want to know is there any other solutions)
2.How to get the hidden trophy's detail?

how can I get my "offline" friends info?

    public function MyFriends($Filter = "online", $Limit = 36)
    {
        $headers = array(
            'Authorization: Bearer ' . $this->oauth
        );
        $response = \Utilities::SendRequest(USERS_URL . "me/friends/profiles2?fields=onlineId,avatarUrls,following,friendRelation,isOfficiallyVerified,personalDetail(@default,profilePictureUrls),personalDetailSharing,plus,presences(@titleInfo,hasBroadcastData,lastOnlineDate),primaryOnlineStatus,trophySummary(@default)&sort=name-onlineId&userFilter=" . $Filter ."&avatarSizes=m&profilePictureSizes=m&offset=0&limit=" . $Limit, $headers, false, null, "GET", null);

        $data = json_decode($response['body'], false);

        return $data;
    }

As you see, the parameter userFilter can be offline for default, But how can I get my "offline" friends?
I try to use "offline" for parameter, but the api returns an parameter error.

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.