SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,834
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)

    How to convert developers Box.View script to PHP curl() format

    I am trying to convert the following scripts supplied in this tutorial to a PHP curl() format:
    http://developers.box.com/viewing-your-first-document/


    Supplied script
    PHP Code:

    $xxx
    =<<<XXX
    curl https://view-api.box.com/1/documents \
    -H "Authorization: Token YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"url": "https://cloud.box.com/shared/static/4qhegqxubg8ox0uj5ys8.pdf"}' \
    -X POST
    XXX;
    echo 
    $xxx

    Desired script
    PHP Code:
    $json       = array ();
    $jsonheader = array 
    (
    "Accept: application/json",
    "Content-type:  application/json"
    "Authorization: TOKEN API-KEY"
    );

    $url 'https://view-api.box.com/1/documents'
         
    '?Authorization= TOKEN API=KEY';

    curl_setopt($chCURLOPT_URL$url);
        
    curl_setopt($chCURLOPT_POST);                 // howmany parameter to post
        
    curl_setopt($chCURLOPT_POSTFIELDS$json ); 
        
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue );    // don't give anything back 
        
    curl_setopt($chCURLOPT_HEADERTRUE );            // need this to evaluate the response .. 
        
    curl_setopt($chCURLOPT_VERBOSEtrue);
        
    curl_setopt($chCURLOPT_HTTPHEADER$jsonheader ); // it is httpheader not httpheader"s" 

        
    $output curl_exec($ch); 

        
    $msg '<br />Operation completed without any errors (only in my dreams)';
        if(
    curl_exec($ch) === false)
        {
          
    $msg '<br />Curl error: ' curl_error($ch);
        }
        echo 
    $msg
    Last edited by John_Betong; Jun 9, 2014 at 01:47. Reason: formatting
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Patche on earning Member of the Month for July 2014

  2. #2
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,834
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    I managed with a little help from my son who found the following:

    GitHub Resource:
    https://github.com/donutdan4114/box-view-api

    PDF Source File:
    http://www.johns-jokes.com/test/donutdan4114/

    HTML Conversion:
    http://www.johns-jokes.com/test/sample-001.pdf
    Last edited by John_Betong; Jun 11, 2014 at 08:55. Reason: formatting
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Patche on earning Member of the Month for July 2014


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •