How to get data using curl or API from http://developers.bringg.com/docs/users

I want only name from http://developers.bringg.com/docs/users using curl in my wordpress custom plugin for custom field Driver_info.

 {
    extract($_POST);
    $url = 'http://parklee.loc/my-spaces-2/';
    $url = 'http://api.bringg.com/partner_api/users'; 

    $ch = curl_init(); 
    curl_setopt($ch,CURLOPT_URL, $url); 
    curl_setopt($ch,CURLOPT_POST,1); 
    curl_setopt($ch,CURLOPT_POSTFIELDS, "id=2"); 
    $result = curl_exec($ch); 
    echo "<pre>"; print_r($result); 
    curl_close($ch);
}

pls tell me whats wrong in this code.I am getting error 404,Not found.
I wrote this line of code inside

Read More
{
    function order_my_custom( $post ){
        $shipping = get_post_meta( $post->ID, 'driver_info', true );

        wp_nonce_field( 'save_BFM_shipping', 'BFM_shipping_nonce' );

        woocommerce_wp_select( array( 'id' => 'driver_info', 'label' => __('Driver Info: ', 'woocommerce'), 'options' => array(
            'OPTION1' => __('c1', 'woocommerce'),
            'OPTION2' => __('c2', 'woocommerce')
            ) ) );

    }
}

And Instead of c1,c2 i wnat name.

Related posts

1 comment

  1. Reading the documentation of how to retreive users, you need to send company_id as a parameter

    $data = [
        'company_id' => $id,
        // paginating data is good, even if it is optional
    ];
    
    $options = array(
        'http' => array(
            'header'  => "Content-type: application/x-www-form-urlencodedrn",
            'method'  => 'POST',
            'content' => http_build_query($data),
        ),
    );
    $context  = stream_context_create($options);
    $response = json_decode(file_get_contents('http://api.bringg.com/partner_api/users', false, $context));
    

    Now all you need is in your response variable, you can dump it to see its content and to know how to loop through it

Comments are closed.