<?php

require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tmhOAuthExample.php';
$tmhOAuth = new tmhOAuthExample();
$code = $tmhOAuth->user_request(array('url' => $tmhOAuth->url('1.1/account/verify_credentials')));
$tmhOAuth->render_response();
<?php

require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tmhOAuthExample.php';
$tmhOAuth = new tmhOAuthExample();
$image = __DIR__ . DIRECTORY_SEPARATOR . 'photo.jpg';
$name = basename($image);
$status = "Picture time";
if (class_exists('CurlFile', false)) {
    $media = new CurlFile($image);
} else {
    $media = "@{$image};type=image/jpeg;filename={$name}";
}
// ref: https://dev.twitter.com/rest/public/uploading-media
// first we post to the media upload endpoint
// then we use the returned information to post to the tweet endpoint
$code = $tmhOAuth->user_request(array('method' => 'POST', 'url' => 'https://upload.twitter.com/1.1/media/upload.json', 'params' => array('media' => $media), 'multipart' => true));
$tmhOAuth->render_response();
// response looks like this:
/*
{
  "media_id": 553656900508606464,
  "media_id_string": "553656900508606464",
  "size": 998865,
  "image": {
    "w": 2234,
    "h": 1873,
    "image_type": "image/jpeg"
  }
}
*/
if ($code == 200) {
Example #3
0
<?php

require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tmhOAuthExample.php';
$tmhOAuth = new tmhOAuthExample();
$code = $tmhOAuth->user_request(array('method' => 'POST', 'url' => $tmhOAuth->url('1.1/friendships/create'), 'params' => array('screen_name' => 'tmhOAuth')));
$tmhOAuth->render_response();
Example #4
0
<?php

require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tmhOAuthExample.php';
$tmhOAuth = new tmhOAuthExample();
$image = __DIR__ . DIRECTORY_SEPARATOR . 'photo.jpg';
$name = basename($image);
$status = "Picture time";
$code = $tmhOAuth->user_request(array('method' => 'POST', 'url' => $tmhOAuth->url('1.1/statuses/update_with_media'), 'params' => array('media[]' => "@{$image};type=image/jpeg;filename={$name}", 'status' => $status), 'multipart' => true));
$tmhOAuth->render_response();
Example #5
0
<?php

require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tmhOAuthExample.php';
$tmhOAuth = new tmhOAuthExample();
$code = $tmhOAuth->user_request(array('method' => 'POST', 'url' => $tmhOAuth->url('1.1/statuses/update'), 'params' => array('status' => 'MTBLS166-1H NMR and LC–MS/MS based urine metabolomic investigation of the subacute effects of HBCD in mice')));
$tmhOAuth->render_response();
Example #6
0
<?php

require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tmhOAuthExample.php';
$tmhOAuth = new tmhOAuthExample();
$code = $tmhOAuth->user_request(array('method' => 'POST', 'url' => $tmhOAuth->url('1.1/statuses/update'), 'params' => array('status' => 'Something for the weekend')));
$tmhOAuth->render_response();
<?php

require __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'tmhOAuthExample.php';
$tmhOAuth = new tmhOAuthExample();
$code = $tmhOAuth->user_request(array('method' => 'GET', 'url' => $tmhOAuth->url('1.1/users/lookup'), 'params' => array('user_id' => array(777925), 'screen_name' => array('tmhoauth'), 'map' => 1)));
$tmhOAuth->render_response();
                $url = sprintf("%s?%s", $url, http_build_query($data));
            }
    }
    // Optional Authentication:
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);
    curl_close($curl);
    return $result;
}
$StudyList = json_decode(CallAPI('GET', 'http://www.ebi.ac.uk/metabolights/webservice/study/list'), true);
foreach ($StudyList['content'] as $study) {
    $StudyDetails = json_decode(CallAPI('GET', 'http://www.ebi.ac.uk/metabolights/webservice/study/' . $study), true);
    $releaseDate = $StudyDetails['content']['studyPublicReleaseDate'];
    $current = strtotime(date("Y-m-d"));
    $date = strtotime($releaseDate);
    $datediff = $date - $current;
    $difference = floor($datediff / (60 * 60 * 24));
    if ($difference == 0) {
        var_dump('Today-' . $study);
        $code = $tmhOAuth->user_request(array('method' => 'POST', 'url' => $tmhOAuth->url('1.1/statuses/update'), 'params' => array('status' => $study . ': ' . $StudyDetails['content']['title'] . ' http://www.ebi.ac.uk/metabolights/' . $study)));
        $tmhOAuth->render_response();
    } else {
        if ($difference > 1) {
            var_dump('Future-' . $study);
        } else {
            var_dump('Published-' . $study);
        }
    }
}