API Request (JSON) to Widget (LocalHost)

  • Unknown's avatar

    Hi,

    I’m super new to WordPress / PHP.
    I’m a Ruby/Rails, Nodejs, JS, developer (mostly) (no CMS usually).

    I’m trying make an API call to a Page/Widget on my WordPress site (Local Environment).

    I put this in my Page editor text:

    <?php
    $response = wp_remote_get( 'https://jsonplaceholder.typicode.com/posts/2' );
    if( is_array($response) ) {
    $header = $response['headers'];
    $body = $response['body'];
    }
    print($response);
    print($header);
    print($body);
    ?>

    It’s not returning anything on my page..

    Is there a way to do this easily? I didn’t install any plugins (I thought it wordpress has the wp_remote_api plugin already integrated on stock).

    I really need this done ASAP !

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    ^^^^^^^^^^^^ignore the “The blog I need help with is: “, i’m not using that one. My site is on my localmachine.

    Also, how do I manually edit PHP files within my dashboard?
    or do I actually have to go into the wordpress folder and go through all the php files and find my file I want to edit?

    Not understanding that concept either.

    Thanks.

  • Unknown's avatar

    No one knows this..?

    19 hours later, i’m still stuck.. Is there a place to post this in wordpress forums? This has to be some-what essential and basic..

  • Unknown's avatar

    Hi there, you’ve posted your question in the forums for sites hosted on WordPressdotcom.

    You’ll want to post this over in the support forums for the standalone WP software. https://wordpress.org/support/ If you need to register a username, you can do so on that page.

    WP and WPcom are separate entities. More about that here: https://en.support.wordpress.com/com-vs-org/

  • The topic ‘API Request (JSON) to Widget (LocalHost)’ is closed to new replies.