Created
April 11, 2013 18:04
-
-
Save tlovett1/5365712 to your computer and use it in GitHub Desktop.
Connect with spoke api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
ini_set('display_errors','On'); | |
/*$con = mysql_connect( 'localhost', 'root', 'ventureTemp' ); | |
if ( ! $con ) { | |
//die( 'Could not connect: ' . mysql_error() ); | |
} | |
mysql_select_db( 'wp_profiles', $con );*/ | |
function request_info_from_spoke( $company_name ) { | |
$url = 'http://www.spoke.com/appany.json'; | |
$content = json_encode( '{ "name": "' . $company_name . '" }'); | |
$curl = curl_init($url); | |
curl_setopt($curl, CURLOPT_HEADER, false); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json")); | |
curl_setopt($curl, CURLOPT_POST, true); | |
curl_setopt($curl, CURLOPT_POSTFIELDS, $content); | |
$json_response = curl_exec($curl); | |
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE); | |
if ( $status != 201 ) { | |
var_dump($json_response); | |
die("Error: call to URL $url failed with status $status, response $json_response, curl_error " . curl_error($curl) . ", curl_errno " . curl_errno($curl)); | |
} | |
curl_close($curl); | |
$response = json_decode($json_response, true); | |
return $response; | |
} | |
$companies = array( | |
'ZocDoc', | |
'Qmobile', | |
'Tableau Software', | |
'Amazon', | |
'YouTube', | |
'Recently Updated Profiles', | |
'miiCard', | |
'Mozilla', | |
'CompStak', | |
'Wandera', | |
'Optimizely', | |
); | |
foreach ( $companies as $company) { | |
$response = request_info_from_spoke( $company ); | |
var_dump( $response ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment