# # next we update # $ret2 = oauth_request($keys, 'http://api.twitter.com/1/account/update_profile.json', array( 'url' => $test_url, ), 'POST'); if (!strlen($ret2)) dump_last_request(); $obj = json_decode($ret2, 1); $new_url = $obj[url]; echo "changed to $new_url<br />"; # # now update again # $ret3 = oauth_request($keys, 'http://api.twitter.com/1/account/update_profile.json', array( 'url' => $orig_url, ), 'POST'); if (!strlen($ret3)) dump_last_request(); $obj = json_decode($ret3, 1); $final_url = $obj[url]; echo "changed back to $final_url<br />"; ?>
<?php include 'lib_oauth.php'; include 'config.php'; $keys = array('oauth_key' => OAUTH_CONSUMER_KEY, 'oauth_secret' => OAUTH_CONSUMER_SECRET, 'user_key' => $_COOKIE[my_acc_key], 'user_secret' => $_COOKIE[my_acc_secret]); $params = array('geolat' => $_REQUEST[lat], 'geolong' => $_REQUEST[long], 'l' => 20); ########################################################################################## # # STEP 3 - access the protected resource # $ret = oauth_request($keys, OAUTH_PROTECTED_URL, $params); if (!strlen($ret)) { dump_last_request(); } //echo $ret; $xml = simplexml_load_string($ret); //print_r($xml); foreach ($xml->group[0]->venue as $value) { echo "<strong>" . $value->name . "</strong><br>"; if (trim($value->address)) { echo $value->address . "<br>"; } if (trim($value->crossstreet)) { echo $value->crossstreet . "<br>"; } if (trim($value->city)) { echo $value->city . "<br>"; } if (trim($value->state)) { echo $value->state . "<br>"; }
$keys = array( 'oauth_key' => OAUTH_CONSUMER_KEY, 'oauth_secret' => OAUTH_CONSUMER_SECRET, 'user_key' => $_COOKIE[my_acc_key], 'user_secret' => $_COOKIE[my_acc_secret], ); ########################################################################################## # # STEP 3 - access the protected resource # $ret = oauth_request($keys, OAUTH_PROTECTED_URL); if (!strlen($ret)) dump_last_request(); ?> <p>Looks like it worked. We asked for your latest tweet and we got:</p> <div style="height: 200px; width: 600px; border: 1px solid #666; overflow: auto;"> <pre><?php echo HtmlSpecialChars($ret); ?> </pre> </div> <p>Refreshing this page will re-request these protected resources.</p>
include 'couchhelper.php'; include 'yahoo_api.php'; $options['host'] = "localhost"; $options['port'] = 5984; $couch = new CouchHelper($options); // See if we can make a connection // read league data // TODO: lookup league_key $resp = $couch->send("GET", "/leagues/348.l.511174"); $league = json_decode($resp, true); $num_teams = $league['fantasy_content']['league'][1]['teams']['count']; for ($i = 0; $i < $num_teams; $i++) { $team = $league['fantasy_content']['league'][1]['teams'][$i]['team']; $team_key = $team[0][0]['team_key']; $url = "http://fantasysports.yahooapis.com/fantasy/v2/team/" . $team_key . "/roster;week=1?format=json"; $data = oauth_request($url); $roster = json_decode($data, true); // check if team exists, grab revision $resp = $couch->send("GET", "/rosters/{$team_key}"); $existing_roster = json_decode($resp, true); if (array_key_exists('_rev', $existing_roster)) { // overwrite existing data $roster['_rev'] = $existing_roster['_rev']; $resp = $couch->send("PUT", "/rosters/{$team_key}", json_encode($roster)); print $resp; } else { $resp = $couch->send("PUT", "/rosters/{$team_key}", json_encode($roster)); print $resp; } }
# (this step adds two keys to the $keys hash) ########################################################################################## # # STEP 2 - exchange the authorized access token for a request token # $ok = oauth_get_access_token($keys, 'http://example.com/access-token-url'); if ($ok){ echo "it worked!"; exit; }else{ die("it didn't work!"); } # (this step adds two more keys to the $keys hash) ########################################################################################## # # STEP 3 - access the protected resource # $ret = oauth_request($keys, "http://example.com/protected-resource"); echo "HTTP response was $ret"; exit; ?>
<?php include 'lib_oauth.php'; include 'config.php'; $keys = array('oauth_key' => OAUTH_CONSUMER_KEY, 'oauth_secret' => OAUTH_CONSUMER_SECRET, 'user_key' => $_COOKIE[my_acc_key], 'user_secret' => $_COOKIE[my_acc_secret]); $params = array('vid' => $_REQUEST[vid], 'shout' => $_REQUEST[shout], 'private' => $_REQUEST[pvt], 'twitter' => $_REQUEST[twitter], 'facebook' => $_REQUEST[facebook], 'geolat' => $_REQUEST[geolat], 'geolong' => $_REQUEST[geolong]); $ret = oauth_request($keys, 'http://api.foursquare.com/v1/checkin', $params, $method = POST); // if (!strlen($ret)) dump_last_request(); $xml = simplexml_load_string($ret); echo $xml->message . "<br>"; echo $xml->mayor->message . "<br>"; echo $xml->scoring->score->points . " points<br>"; echo $xml->scoring->score->message;