MySpace Open Platform

A Place For Developers

Welcome Developers!

in

Welcome!

in

Another MySpace PHP REST API Library

Last post 04-10-2008 8:05 AM by AppAuthor. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 03-18-2008 2:30 PM

    Another MySpace PHP REST API Library

  • 03-26-2008 4:34 PM In reply to

    Re: Another MySpace PHP REST API Library

    This official library looks great. Anyone have a simple walkthorugh on how to install PEAR?

  • 03-27-2008 4:56 AM In reply to

    Re: Another MySpace PHP REST API Library

    Tom's Apps:

    This official library looks great. Anyone have a simple walkthorugh on how to install PEAR?

    Are you on a shared host or a VPS/dedicated server? Usually PEAR will already be installed, and PEAR modules (whatever they're called) are installed via the "pear install [module name]" command in a terminal. If you don't have shell access, your web host's control panel might have an option to install PERL modules (eg. cPanel 11 does). Otherwise, if you can't do that, just download the required modules from http://pear.php.net/ and put them in either your include path (in php.ini, shown on a phpinfo() page) or your app's directory :)

  • 03-27-2008 8:35 PM In reply to

    • CC
    • Top 200 Contributor
    • Joined on 02-08-2008
    • Posts 25

    Re: Another MySpace PHP REST API Library

    I uploaded the modules from pear.php.net to my include path and it works.

    Here are the packages

    http://download.pear.php.net/package/HTTP_Request-1.4.2.tgz
    http://download.pear.php.net/package/Net_Socket-1.0.8.tgz
    http://download.pear.php.net/package/Net_URL-1.0.15.tgz

    I placed files in following directory structure

    PHPLib/myspace/HTTP/Request.php
    PHPLib/myspace/HTTP/Request/Listener.php
    PHPLib/myspace/HTTP/Net/Socket.php
    PHPLib/myspace/HTTP/Net\URL.php

     

    http://.............../PHPLib/MSAPI-TestAllGets.php  seems  to work fine but http://............../PHPLib/MSAPI-TestAllPosts.php doesnot work for me.
    I changed few lines of code in BaseAPI.php

    line 108:   curl_setopt($curl, CURLOPT_POST, 1);
    line 109:   $http_util = new HttpUtil();
    line 110:   curl_setopt($curl, CURLOPT_POSTFIELDS, $http_util->convert_post_data($post_data));

    Then after i get this message

    put_moodstring(1019) "

    Service


    Method not allowed.

    "

     

    Also http://.............../PHPLib/OSAPI-TestAllGets.php  didn't work


    Fatal error: Uncaught exception 'Exception' with message '401 <error xmlns="api-v1.myspace.com"><statuscode>401</statuscode><message>Invalid length for a Base-64 char array.</message></error>' in /home/match/public_html/PHPLib/myspace/BaseAPI.php:62 Stack trace: #0 /home/match/public_html/PHPLib/myspace/MyOpenSpaceAPI.php(151): BaseAPI->_do_get('http://api.msap...', NULL) #1 /home/match/public_html/PHPLib/myspace/MyOpenSpaceAPI.php(43): MyOpenSpaceAPI->do_get('VIEWER', 'profile', NULL) #2 /home/match/public_html/PHPLib/OSAPI-TestAllGets.php(23): MyOpenSpaceAPI->get_profile() #3 {main} thrown in /home/match/public_html/PHPLib/myspace/BaseAPI.php on line 62 

    where can i get Base-64 char array for

    $opensocial_token = "MIGvBgorBgEEAYI3WAPjoIGgMIGdBM6oSO%2fvm1IkutjJa%2bHiQ%3d%3d"; // <-- CHANGE THIS

     

    Binay 

     

  • 04-02-2008 7:36 AM In reply to

    • Josh
    • Not Ranked
    • Joined on 04-01-2008
    • Posts 3

    Re: Another MySpace PHP REST API Library

    I have the same question.  Where do I find my opensocial_token? 

  • 04-03-2008 6:43 AM In reply to

    Re: Another MySpace PHP REST API Library

     Hi i also got this error "Fatal error: Uncaught exception 'Exception' with message '401 <error xmlns="api-v1.myspace.com"><statuscode>401</statuscode><message>User has not installed the current application.</message></error>' in C:\wamp\www\popflyz\myspace\BaseAPI.php:86 Stack trace: #0 C:\wamp\www\popflyz\myspace\MySpaceAPI.php(171): BaseAPI->_do_get('http://api.mysp...', NULL) #1 C:\wamp\www\popflyz\myspace\MySpaceAPI.php(32): MySpaceAPI->do_get('users/264730435', NULL) #2 C:\wamp\www\popflyz\MSAPI-TestAllGets.php(52): MySpaceAPI->get_user(264730435) #3 {main} thrown in C:\wamp\www\popflyz\myspace\BaseAPI.php on line 86"  Please help to resolve this problem.

  • 04-03-2008 9:23 PM In reply to

    • CC
    • Top 200 Contributor
    • Joined on 02-08-2008
    • Posts 25

    Re: Another MySpace PHP REST API Library

     Hi,

    Just forget this official php client library till they review it again.

    Use this one http://www.frencaze.com/myspace-platform.tar.gz posted by jerome it works great

    But on space.php on line 28 change as below:

    private $sServer  = 'http://api.myspace.com/';

    I am using external IFRAME in canvas page pointing to my index page where i store signature and other parameters passed by myspace in session variable after authenticating signature.

    //index.php page

    <?php
        session_start();
        require_once("myspace-platform/space.php");
        if($_GET[opensocial_viewer_id])
        {     
            $remote_signature = $_GET['oauth_signature'];
            foreach( $_GET as $key => $val )
            if( !isset( $_POST[ $key ] ) )
                        $_POST[ $key ] = $val;

            $local_signature = OAuthRequest::from_request()->build_signature(
                                new OAuthSignatureMethod_HMAC_SHA1(),
                                new OAuthConsumer( API_KEY, SECRET_KEY),
                                new OAuthToken(null,null)
                       );      
                     
           
            if ($remote_signature == $local_signature)   //check local generated signature and remote signature passed by myspace
            {
                $user = $_GET[opensocial_viewer_id];
                $_SESSION[data]=$_GET;
            }
        }
        else
        {
            $user = $_SESSION[data][opensocial_viewer_id];
        }
        $myspace = new Space(MYSPACE_API_KEY, MYSPACE_SECRET_KEY);
        try
        {
            $result = $myspace->user($user);
        }
        catch(Exception $e)
        {
            //app not installed redirect to app profile
           header("Location: MYSPACE_APP_PROFILE_URL");
        }

       // authenticated user do what ever u like below :)

    ?>

     Signature is passed only to index page specified in external IFRAME so we stored it in session to check for authenitcated user in other pages than index.php

    //otherpages.php

    <?php
        session_start();
        $user = $_SESSION[data][opensocial_viewer_id];
        if($user == null)
        {
             //session not set        
             echo "You are not authenticated user";
             exit();
        }
       

       //authenticated user do what ever u like :)

    ?>

    MDP team please review the official php library

    Thank you

  • 04-04-2008 5:13 AM In reply to

    Re: Another MySpace PHP REST API Library

     Hello friend will you give me sample canvas code.

     Sanjeev. 

  • 04-08-2008 11:35 PM In reply to

    Re: Another MySpace PHP REST API Library

    hi,

    Here is the example of sample canvas page code by javascipt. 

    http://developer.myspace.com/Community/blogs/devteam/archive/2008/02/19/where-s-my-data-api.aspx 

     

     

  • 04-10-2008 8:05 AM In reply to

    Re: Another MySpace PHP REST API Library

    I received the following error when I attemped to use WinZip to open the PHP libary from the URL that CommentCherry provided:

    Error reading header after processing 3 entries.

    The URL provided by FriendsEAT.com was for a posting from 2/19/08. That post contains no reference to the 'oauth_signature' parameter.

    I am trying to use the Install Callback URL. When my App is installed, my PHP script is called, but none of the code posted on these forums will correctly validate the oauth_signature with the OAuth Consumer Secret.

    Can someone please provide some code that actually works. I have also requested this information at the following post:

    http://developer.myspace.com/Community/forums/t/1661.aspx

     

     

Page 1 of 1 (10 items)