PHP / curl

27 views
Skip to first unread message

Aaron

unread,
May 25, 2016, 9:40:12 PM5/25/16
to Rhapsody API
Does anyone have any good examples of using the provided curl comments within a PHP framework?

Thanks!

Aaron

Aaron

unread,
May 25, 2016, 11:12:09 PM5/25/16
to Rhapsody API
Well I think I figured it out!

<?php 
curl_setopt($curl, CURLOPT_VERBOSE, true); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_USERPWD, 'xxxxxxxxxxxxxx}:{xxxxxxxxxxxxx}'); 
curl_setopt($curl, CURLOPT_POSTFIELDS, 'username=xxxxx...@gmail.com&password=secret&grant_type=xxxxxx'); 

$result = curl_exec($curl); 
echo $result; 
?>

The only problem, is I get the same error as I do in my other post... At least this time its in HTML.

Proxy Error

The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request POST /oauth/token.

Reason: Error reading from remote server


Apache Server at api.rhapsody.com Port 80

Richard Luck

unread,
Jun 8, 2016, 4:07:20 PM6/8/16
to Rhapsody API
Aaron,

I think the problem is with your use of "CURLOPT_USERPWD".   See this post.  I think you can solve this by setting the header directly:

$headers = array("Authorization: Basic " base64_encode("USERNAME:PASSWORD"));
curl_setopt($chCURLOPT_HTTPHEADER$headers);  

Let me know if this works for you,

Richard

Aaron

unread,
Dec 9, 2016, 11:40:53 AM12/9/16
to Rhapsody API
I never thanked you for your reply!  I just fired up building a new web application and posted a question in the Napster Forum. 
Reply all
Reply to author
Forward
0 new messages