예제 #1
0
파일: example.php 프로젝트: lildude/phpsmug
    <title>phpSmug First Album Example</title>
    <style type="text/css">
        body { background-color: #fff; color: #444; font-family: sans-serif; }
        div { width: 750px; margin: 0 auto; text-align: center; }
        img { border: 0;}
    </style>
</head>
<body>
    <div>
        <a href="http://phpsmug.com"><img src="phpSmug-logo.svg" /></a>
        <h2>phpSmug First Album Example</h2>
<?php 
require_once 'vendor/autoload.php';
try {
    $options = ['AppName' => $AppName, '_verbosity' => 1];
    $client = new phpSmug\Client($APIKey, $options);
    // Get the first public album
    $albums = $client->get("user/{$username}!albums", array('count' => 1));
    // Get the first 25 photos in the album
    $images = $client->get($albums->Album[0]->Uris->AlbumImages, array('count' => 25));
    // Display the image thumbnails.
    foreach ($images->AlbumImage as $image) {
        printf('<a href="%s"><img src="%s" title="%s" alt="%s" width="150" height="150" /></a>', $image->WebUri, $image->ThumbnailUrl, $image->Title, $image->ImageKey);
    }
} catch (Exception $e) {
    printf('%s (Error Code: %d)', $e->getMessage(), $e->getCode());
}
?>
    </div>
</body>
</html>
예제 #2
0
<head>
    <title>phpSmug OAuth Login Example</title>
    <style type="text/css">
        body { background-color: #fff; color: #444; font-family: sans-serif }
        div { width: 750px; margin: 0 auto; text-align: center; }
        img { border: 0;}
    </style>
</head>
<body>
    <div>
        <a href="http://phpsmug.com"><img src="phpSmug-logo.svg" /></a>
        <h1>OAuth Login Example</h1>
<?php 
try {
    $options = ['AppName' => $AppName, '_verbosity' => 1, 'OAuthSecret' => $OAuthSecret];
    $client = new phpSmug\Client($APIKey, $options);
    // Perform the 3 step OAuth Authorisation process.
    // NOTE: This is a very simplified example that does NOT store the final token.
    // You will need to ensure your application does.
    if (!isset($_SESSION['SmugGalReqToken'])) {
        // Step 1: Get a request token using an optional callback URL back to ourselves
        $callback = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['SCRIPT_NAME'];
        $request_token = $client->getRequestToken($callback);
        $_SESSION['SmugGalReqToken'] = serialize($request_token);
        // Step 2: Get the User to login to SmugMug and authorise this demo
        echo '<p>Click <a href="' . $client->getAuthorizeURL() . '"><strong>HERE</strong></a> to Authorize This Demo.</p>';
        // Alternatively, automatically direct your visitor by commenting out the above line in favour of this:
        //header("Location:".$client->getAuthorizeURL());
    } else {
        $reqToken = unserialize($_SESSION['SmugGalReqToken']);
        unset($_SESSION['SmugGalReqToken']);
예제 #3
0
<head>
    <title>phpSmug External Links Example</title>
    <style type="text/css">
        body { background-color: #fff; color: #444; font-family: sans-serif }
        div { width: 750px; margin: 0 auto; text-align: center; }
        img { border: 0;}
    </style>
</head>
<body>
    <div>
        <a href="http://phpsmug.com"><img src="phpSmug-logo.svg" /></a>
        <h1>External Links Example</h1>
<?php 
try {
    $options = ['AppName' => $AppName, '_verbosity' => 1, 'OAuthSecret' => $OAuthSecret];
    $client = new phpSmug\Client($APIKey, $options);
    // Perform the 3 step OAuth Authorisation process.
    // NOTE: This is a very simplified example that does NOT store the final token.
    // You will need to ensure your application does.
    if (!isset($_SESSION['SmugGalReqToken'])) {
        // Step 1: Get a request token using an optional callback URL back to ourselves
        $callback = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['SCRIPT_NAME'];
        $request_token = $client->getRequestToken($callback);
        $_SESSION['SmugGalReqToken'] = serialize($request_token);
        // Step 2: Get the User to login to SmugMug and authorise this demo
        echo '<p>Click <a href="' . $client->getAuthorizeURL() . '"><strong>HERE</strong></a> to Authorize This Demo.</p>';
        // Alternatively, automatically direct your visitor by commenting out the above line in favour of this:
        //header("Location:".$client->getAuthorizeURL());
    } else {
        $reqToken = unserialize($_SESSION['SmugGalReqToken']);
        unset($_SESSION['SmugGalReqToken']);