• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

phpcurlyoutube


PHP Snippet 1:

function http_get_contents($url)
{
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_TIMEOUT, 1);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  if (FALSE === ($retval = curl_exec($ch))) {
    echo curl_error($ch);
  } else {
    return $retval;
  }
}

$request_url = 'http://gdata.youtube.com/feeds/api/videos/SD3S27fMGzc';
$result = http_get_contents($request_url);

$simpleXML = new SimpleXMLElement($result);

print_r($simpleXML);

Related Snippets

advanced custom fields wordpress custom class

unable to load your default controller on Codeigniter

PHP header location absolute URL

How to get the survey List from surveygizmo API in the Postman?(Trial Version)

How to remove index.php and index from the URL using htaccess | PHP

Sagepay Error The Vendor failed to provide a RedirectionURL

Reorder attribute dropdown terms in Woocommerce single variable products

Attempted to call an undefined method named "get" of class "MailController"

stay with the last 15 elements of an array [duplicate]

Timber: Single post pagination does not work (wp_link_pages)

php curl_exec() Connection refused when retrieving a remote image

oauth-private.key does not exist or is not readable

Laravel Mix Uncaught ReferenceError: $ is not defined

Group rows by column and sum another column within groups [duplicate]

Exact alternate to mcrypt_encrypt in PHP 7.2

About Contact Privacy policy Terms and conditions