当前位置: 首页>>代码示例>>PHP>>正文


PHP CASHSystem::getURLContents方法代码示例

本文整理汇总了PHP中CASHSystem::getURLContents方法的典型用法代码示例。如果您正苦于以下问题:PHP CASHSystem::getURLContents方法的具体用法?PHP CASHSystem::getURLContents怎么用?PHP CASHSystem::getURLContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CASHSystem的用法示例。


在下文中一共展示了CASHSystem::getURLContents方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testValidReturn

 function testValidReturn()
 {
     if ($this->cash_test_url) {
         $return = json_decode(CASHSystem::getURLContents(CASH_API_URL . 'verbose/element/getmarkup/100/status_uid/whatever', false, true));
         // test valid JSON:
         $this->assertNotNull($return);
         // make sure all the bits and pieces are in place
         $this->assertTrue(isset($return->status_code));
         $this->assertTrue(isset($return->status_uid));
         $this->assertTrue(isset($return->status_message));
         $this->assertTrue(isset($return->contextual_message));
         $this->assertTrue(isset($return->request_type));
         $this->assertTrue(isset($return->action));
         $this->assertTrue(isset($return->payload));
         $this->assertTrue(isset($return->api_version));
         $this->assertTrue(isset($return->timestamp));
         // test types for the standardized bits, ignore the variable pieces
         $this->assertTrue(is_int($return->status_code));
         $this->assertTrue(is_string($return->status_uid));
         $this->assertTrue(is_string($return->status_message));
         $this->assertTrue(is_string($return->contextual_message));
         $this->assertTrue(is_string($return->request_type));
         $this->assertTrue(is_string($return->action));
         $this->assertTrue(is_int($return->api_version));
         $this->assertTrue(is_int($return->timestamp));
     }
 }
开发者ID:blacktire,项目名称:DIY,代码行数:27,代码来源:300_BasicHTTPAPITests.php

示例2: testURLsAndContent

 function testURLsAndContent()
 {
     if ($this->s3_key) {
         $s3 = new S3Seed($this->cash_user_id, $this->s3_connection_id);
         // check for the timestamp in the public link for the public test file
         $test_content = CASHSystem::getURLContents('http://' . $this->s3_bucket . '.s3.amazonaws.com/' . 'test' . $this->timestamp);
         $this->assertPattern('/' . $this->timestamp . '/', $test_content);
         // and in the private link generated for the private test file
         $test_content = CASHSystem::getURLContents($s3->getExpiryURL('test_private' . $this->timestamp, 20));
         $this->assertPattern('/' . $this->timestamp . '/', $test_content);
         // now test headers -- relies on fopen wrappers
         if (ini_get('allow_url_fopen')) {
             // first defaults, both present:
             file_get_contents($s3->getExpiryURL('test_private' . $this->timestamp, 20));
             $this->assertTrue(array_search('Content-Disposition: attachment', $http_response_header));
             $this->assertTrue(array_search('Cache-Control: no-cache', $http_response_header));
             // no-cache only:
             file_get_contents($s3->getExpiryURL('test_private' . $this->timestamp, 20, false, true));
             $this->assertFalse(array_search('Content-Disposition: attachment', $http_response_header));
             $this->assertTrue(array_search('Cache-Control: no-cache', $http_response_header));
             // attachment only:
             file_get_contents($s3->getExpiryURL('test_private' . $this->timestamp, 20, true, false));
             $this->assertTrue(array_search('Content-Disposition: attachment', $http_response_header));
             $this->assertFalse(array_search('Cache-Control: no-cache', $http_response_header));
         }
     }
 }
开发者ID:JamesLinus,项目名称:platform,代码行数:27,代码来源:103_S3Seed.php

示例3: getUser

 public function getUser($username, $extended_detail = false)
 {
     $username = str_replace('@', '', $username);
     $endoint_url = 'https://api.twitter.com/1/users/show.json?screen_name=' . $username;
     $user_data = json_decode(CASHSystem::getURLContents($endoint_url), true);
     if ($user_data && !$extended_detail) {
         // let's trim out some of the things we don't need
         unset($user_data['status']);
         unset($user_data['follow_request_sent']);
         unset($user_data['profile_background_color']);
         unset($user_data['profile_background_tile']);
         unset($user_data['profile_sidebar_fill_color']);
         unset($user_data['notifications']);
         unset($user_data['default_profile_image']);
         unset($user_data['show_all_inline_media']);
         unset($user_data['profile_sidebar_border_color']);
         unset($user_data['following']);
         unset($user_data['is_translator']);
         unset($user_data['profile_use_background_image']);
         unset($user_data['profile_text_color']);
         unset($user_data['profile_background_image_url']);
         unset($user_data['profile_link_color']);
     }
     return $user_data;
 }
开发者ID:blacktire,项目名称:DIY,代码行数:25,代码来源:TwitterSeed.php

示例4: postToPaypal

 protected function postToPaypal($method_name, $nvp_parameters)
 {
     // Set the API operation, version, and API signature in the request.
     $request_parameters = array('METHOD' => $method_name, 'VERSION' => $this->api_version, 'PWD' => $this->api_password, 'USER' => $this->api_username, 'SIGNATURE' => $this->api_signature);
     $request_parameters = array_merge($request_parameters, $nvp_parameters);
     // Get response from the server.
     $http_response = CASHSystem::getURLContents($this->api_endpoint, $request_parameters, true);
     if ($http_response) {
         // Extract the response details.
         $http_response = explode("&", $http_response);
         $parsed_response = array();
         foreach ($http_response as $i => $value) {
             $tmpAr = explode("=", $value);
             if (sizeof($tmpAr) > 1) {
                 $parsed_response[$tmpAr[0]] = urldecode($tmpAr[1]);
             }
         }
         if (0 == sizeof($parsed_response) || !array_key_exists('ACK', $parsed_response)) {
             $this->setErrorMessage("Invalid HTTP Response for POST (" . $nvpreq . ") to " . $this->api_endpoint);
             return false;
         }
         if ("SUCCESS" == strtoupper($parsed_response["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($parsed_response["ACK"])) {
             return $parsed_response;
         } else {
             $this->setErrorMessage(print_r($parsed_response, true));
             return false;
         }
     } else {
         $this->setErrorMessage('could not reach Paypal servers');
         return false;
     }
 }
开发者ID:blacktire,项目名称:DIY,代码行数:32,代码来源:PaypalSeed.php

示例5: test_getURLContents

 function test_getURLContents()
 {
     if (getTestEnv('CASHMUSIC_TEST_URL') == 'http://dev.cashmusic.org:8080' && !strpos(CASH_API_URL, 'localhost')) {
         // Test URL set to remote, so skip the local test
         echo "Testing getURLContents with cashmusic.org because of remote test URL.\n";
         $return = CASHSystem::getURLContents('http://cashmusic.org/');
         $this->assertPattern('/cash/', $return);
         // use google
     } else {
         $return = CASHSystem::getURLContents(CASH_API_URL);
         $this->assertPattern('/"greeting":"hi."/', $return);
         // using local API URL as firewalls could mess with an external test
     }
 }
开发者ID:blacktire,项目名称:DIY,代码行数:14,代码来源:007_CASHSystem.php

示例6: getAPIDetails

 /**
  * Returns the (best guess at) APE URL
  * fix that typo. I refuse. It's too funny.
  *
  * @return array
  */
 public static function getAPIDetails()
 {
     if (!defined('STDIN')) {
         // check for command line
         $api_url = 'http' . (empty($_SERVER['HTTPS']) && $_SERVER['SERVER_PORT'] != 443 ? '' : 's') . '://' . $_SERVER['HTTP_HOST'] . str_replace('/admin', '/api', ADMIN_WWW_BASE_PATH);
         $api_response = json_decode(CASHSystem::getURLContents($api_url));
         if ($api_response->greeting == 'hi.') {
             return array('api_url' => $api_url, 'api_version' => $api_response->api_version);
         } else {
             return false;
         }
         return $api_url;
     } else {
         return false;
     }
 }
开发者ID:nodots,项目名称:DIY,代码行数:22,代码来源:AdminHelper.php

示例7: getCachedURL

 /**
  * Takes a cache name, data name, and URL — first looks for viable cache data, 
  * then 
  *
  * @return int (remaining time in seconds) or false
  */
 protected function getCachedURL($cache_name, $data_name, $data_url, $format = 'json', $decode = true)
 {
     $url_contents = $this->getCacheData($cache_name, $data_name, false, $decode);
     if (!$url_contents) {
         $url_contents = CASHSystem::getURLContents($data_url);
         if (!$url_contents) {
             $url_contents = $this->getCacheData($cache_name, $data_name, true, $decode);
         } else {
             if ($format == 'json') {
                 $url_contents = json_decode($url_contents);
             }
             $this->setCacheData($cache_name, $data_name, $url_contents);
         }
     }
     return $url_contents;
 }
开发者ID:nodots,项目名称:DIY,代码行数:22,代码来源:CASHData.php

示例8: testProcessWebhooks

 function testProcessWebhooks()
 {
     $time = time();
     // only run if key / list have been set properly
     if ($this->api_key && $this->api_list_id) {
         $data_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'getapicredentials', 'user_id' => $this->cash_user_id));
         $api_credentials = $data_request->response['payload'];
         // valid API url, but likely localhost
         $webhook_api_url = CASH_API_URL . '/verbose/people/processwebhook/origin/com.mailchimp/list_id/' . $this->test_list_id . '/api_key/' . $api_credentials['api_key'];
         // make sure we're rejecting bad keys
         $bad_webhook_api_url = CASH_API_URL . '/verbose/people/processwebhook/origin/com.mailchimp/list_id/' . $this->test_list_id . '/api_key/incorrect';
         $response = json_decode(CASHSystem::getURLContents($bad_webhook_api_url, array('sample' => 'data'), true));
         // TODO: this is currently returning 400, we need to get that to 403, but we'll test for not-200
         //       which at least proves we're not accepting bad keys
         $this->assertNotEqual($response->status_code, 200);
         $test_address = 'dev+shouldnotsubscribe' . $time . '@cashmusic.org';
         $add_post_data = array("type" => "subscribe", "fired_at" => "2009-03-26 21:35:57", "data" => array("id" => "8a25ff1d98", "list_id" => "a6b5da1054", "email" => $test_address, "email_type" => "html", "merges" => null, "ip_opt" => "10.20.10.30", "ip_signup" => "10.20.10.30"));
         CASHSystem::getURLContents($webhook_api_url, $add_post_data, true);
         $list_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'getaddresslistinfo', 'list_id' => $this->test_list_id, 'address' => $test_address));
         // make sure that the address has been added to the local list
         $this->assertTrue($list_request->response['payload']);
         $remove_post_data = array("type" => "unsubscribe", "fired_at" => "2009-03-26 21:36:52", "data" => array("id" => "8a25ff1d98", "action" => "unsub", "reason" => "manual", "list_id" => "a6b5da1054", "email" => $test_address, "email_type" => "html", "merges" => null, "ip_opt" => "10.20.10.30", "ip_signup" => "10.20.10.30"));
         CASHSystem::getURLContents($webhook_api_url, $remove_post_data, true);
         $list_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'getaddresslistinfo', 'list_id' => $this->test_list_id, 'address' => $test_address));
         // now make sure that the address has been removed
         $this->assertEqual($list_request->response['payload']['active'], 0);
     }
 }
开发者ID:umamiMike,项目名称:platform,代码行数:28,代码来源:101_MailchimpSeed.php

示例9: getUserOrPage

 public function getUserOrPage($id)
 {
     $endoint_url = 'https://graph.facebook.com/' . $id;
     $user_data = json_decode(CASHSystem::getURLContents($endoint_url), true);
     return $user_data;
 }
开发者ID:blacktire,项目名称:DIY,代码行数:6,代码来源:FacebookSeed.php

示例10: getBrowserIdStatus

 public static function getBrowserIdStatus($assertion, $return_details = false)
 {
     if (!$assertion) {
         return false;
     } else {
         $post_data = array('assertion' => $assertion, 'audience' => CASHSystem::getCurrentURL(true));
         $status = json_decode(CASHSystem::getURLContents('https://browserid.org/verify', $post_data, true), true);
         if ($return_details || !$status) {
             return $status;
         } else {
             if ($status['status'] == 'okay') {
                 return $status['email'];
             } else {
                 return false;
             }
         }
     }
 }
开发者ID:nodots,项目名称:DIY,代码行数:18,代码来源:CASHSystem.php

示例11: testProcessWebhooks

 function testProcessWebhooks()
 {
     $time = time();
     if ($this->api_key) {
         $data_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'getapicredentials', 'user_id' => $this->cash_user_id));
         $api_credentials = $data_request->response['payload'];
         // valid API url, but likely localhost
         $webhook_api_url = CASH_API_URL . 'verbose/people/processwebhook/origin/com.mailchimp/list_id/' . $this->test_list_id . '/api_key/' . $api_credentials['api_key'];
         $test_address = 'dev+shouldnotsubscribe' . $time . '@cashmusic.org';
         $add_post_data = array("type" => "subscribe", "fired_at" => "2009-03-26 21:35:57", "data" => array("id" => "8a25ff1d98", "list_id" => "a6b5da1054", "email" => $test_address, "email_type" => "html", "merges" => null, "ip_opt" => "10.20.10.30", "ip_signup" => "10.20.10.30"));
         CASHSystem::getURLContents($webhook_api_url, $add_post_data, true);
         $list_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'getaddresslistinfo', 'list_id' => $this->test_list_id, 'address' => $test_address));
         // make sure that the address has been added to the local list
         $this->assertTrue($list_request->response['payload']);
         $remove_post_data = array("type" => "unsubscribe", "fired_at" => "2009-03-26 21:36:52", "data" => array("id" => "8a25ff1d98", "action" => "unsub", "reason" => "manual", "list_id" => "a6b5da1054", "email" => $test_address, "email_type" => "html", "merges" => null, "ip_opt" => "10.20.10.30", "ip_signup" => "10.20.10.30"));
         CASHSystem::getURLContents($webhook_api_url, $remove_post_data, true);
         $list_request = new CASHRequest(array('cash_request_type' => 'people', 'cash_action' => 'getaddresslistinfo', 'list_id' => $this->test_list_id, 'address' => $test_address));
         // now make sure that the address has been removed
         $this->assertEqual($list_request->response['payload']['active'], 0);
     } else {
         fwrite(STDERR, "Mailchimp api key not found, skipping mailchimp tests\n");
         return;
     }
 }
开发者ID:nodots,项目名称:DIY,代码行数:24,代码来源:101_MailchimpSeed.php

示例12: file_put_contents

<?php

if (isset($_POST['doupgrade'])) {
    $upgrade_file_contents = CASHSystem::getURLContents('https://raw.github.com/cashmusic/platform/latest_stable/installers/php/update/update.php');
    if ($upgrade_file_contents) {
        $success = file_put_contents(ADMIN_BASE_PATH . '/../update.php', $upgrade_file_contents);
        if ($success) {
            AdminHelper::controllerRedirect('/../update.php');
        } else {
            $cash_admin->page_data['error_message'] = 'Trouble copying update tool. Please make sure you have write permissions and try again.';
        }
    } else {
        $cash_admin->page_data['error_message'] = 'Failed to get the update tool. Please try again.';
    }
}
$cash_admin->page_data['platform_version'] = CASHRequest::$version;
$cash_admin->page_data['upgrade_available'] = false;
$current_profile_url = 'https://raw.github.com/cashmusic/platform/latest_stable/installers/php/update/releaseprofiles/release_' . $cash_admin->page_data['platform_version'] . '.json';
if (CASHSystem::getURLContents($current_profile_url)) {
    // found stable upgrade path...neat! let's check for a proper upgrade script:
    $upgrade_script_url = 'https://raw.github.com/cashmusic/platform/latest_stable/installers/php/update/updatescripts/' . $cash_admin->page_data['platform_version'] . '.php';
    $upgrade_script_contents = CASHSystem::getURLContents($upgrade_script_url);
    if ($upgrade_script_contents) {
        // okay rad, got an upgrade script too.
        $cash_admin->page_data['upgrade_available'] = true;
    }
} else {
    $cash_admin->page_data['is_edge'] = true;
}
$cash_admin->setPageContentTemplate('settings_update');
开发者ID:JamesLinus,项目名称:platform,代码行数:30,代码来源:settings_update.php

示例13: test_getURLContents

 function test_getURLContents()
 {
     $return = CASHSystem::getURLContents(CASH_API_URL);
     $this->assertPattern('/"greeting":"hi."/', $return);
     // using local API URL as firewalls could mess with an external test
 }
开发者ID:nodots,项目名称:DIY,代码行数:6,代码来源:007_CASHSystem.php


注:本文中的CASHSystem::getURLContents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。