Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. $url2 = 'https://watson-api-explorer.mybluemix.net/personality-insights/api/v3/profile?raw_scores=false&csv_headers=false&consumption_preferences=true&version=2017-02-01';
  2. $request_headers = array();
  3. $request_headers[] = 'Accept: application/json';
  4. $request_headers[] = 'Content-Type: text/plain';
  5.  
  6. $request_headers[] = 'Content-Language: en';
  7. $request_headers[] = 'Accept-Language: en';
  8.  
  9. $simple_data = 'some really interesting text goes here';
  10.  
  11.  
  12. $plain_data = json_encode($data);
  13. $ch2 = curl_init( $url2 );
  14. curl_setopt_array( $ch2, array(
  15. CURLOPT_POST => 1,
  16. CURLOPT_POSTFIELDS => $simple_data,
  17. CURLOPT_FOLLOWLOCATION => 1,
  18. CURLOPT_HEADER => $request_headers,
  19. CURLOPT_RETURNTRANSFER => 1,
  20. CURLOPT_USERPWD => 'XXX:YYY' //removed for illustration
  21. )
  22. );
  23. $response2 = curl_exec( $ch2 );
  24. var_dump($response2);
  25.  
  26. {"code":415,"sub_code":"S00002","error":"Unsupported Content-Type: "application/x-www-form-urlencoded""}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement