Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8513675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:38:31+00:00 2026-06-11T04:38:31+00:00

I am trying to do the following. When I try to access a service

  • 0

I am trying to do the following.

When I try to access a service using oAuth, if I get an error, because I am using a wrong key, I want to not show the error messages, but instead send the user to the authentication page.

However using a try catch fn does not work.

This is my code:

$url = 'https://api.soundcloud.com/me.json?'.http_build_query(array(
        'oauth_token' => $token,
    ));
    //
    try{
        $user = json_decode(file_get_contents($url));
        return array(
            'uid' => $user->id,
            'nickname' => $user->username,
            'name' => $user->full_name,
            'location' => $user->country.' ,'.$user->country,
            'description' => $user->description,
            'image' => $user->avatar_url,
            'urls' => array(
                'MySpace' => $user->myspace_name,
                'Website' => $user->website,
            ),
        );
    }
    catch(Services_Soundcloud_Invalid_Http_Response_Code_Exception $e)
    {
        log_message('error', 'EXCEPTION: '.$e);
        return FALSE;
    }

I want this to either return the user array or FALSE.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:38:32+00:00Added an answer on June 11, 2026 at 4:38 am

    You can take a look here for catching file_get_content error

    How can I handle the warning of file_get_contents() function in PHP?

    That offers different solutions like looking at the response header

    $content = @file_get_contents("http://www.google.com");
    if (strpos($http_response_header[0], "200")) { 
       echo "SUCCESS";
    } else { 
       echo "FAILED";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to send email using c# following is my code. try {
I am trying following, 1. Get response using Ajax from the users selection which
I seem to be getting the following error when I try to access a
I'm trying to access a WCF service, exposed using basicHttpBinding, inside an ASP.NET 2.0
I am receiving the following error when trying to access font file : 011.08.31
I'm getting the following error when I try to access a page that's supposed
I'm trying to achieve the following with a bash script: try for SSH connection,
I am trying the following query and get only zero results (I am supposed
I'm trying the following and cannot find out what is wrong: IF( IFNULL( SELECT
I'm trying to host a WCF service in IIS so that I can access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.