Skip to content
Hunter Wu edited this page Sep 16, 2020 · 2 revisions

Crowdin

https://crowdin.com/api/v2/languages

Github v4

Issues

query ListIssues {
  repository(owner: "wmh", name: "myproject1") {
    issues(last: 3) {
      edges {
        node {
          id
        }
      }
    }
  }
}
query FindIssue {
  repository(owner: "wmh", name: "myproject1") {
    issue(number: 1) {
      id
      body
    }
  }
}
query nodeQuery {
  node(id: "MDU6SXNzdWUzNTUwMzU1NjY=") {
    __typename
  }
}
mutation AddReactionToIssue {
  addReaction(input: {subjectId: "MDU6SXNzdWUzNTUwMzU1NjY=", content: HEART}) {
    clientMutationId
  }
}
mutation removeReaction {
  removeReaction(input: {subjectId: "MDU6SXNzdWUzNTUwMzU1NjY=", content: HEART}) {
    clientMutationId
  }
}

mandrillapp.com

<?php
try {
  require_once 'src/Mandrill.php';
  $mandrill = new Mandrill('API-KEY');
  $message = array(
    'html' => file_get_contents('email.html'),
    'subject' => '十週年!',
    'from_email' => '[email protected]',
    'from_name' => '站長',
    'to' => array(
      array(
        'email' => '[email protected]',
      ),
    )
  );
  $async = false;
  $ip_pool = 'Main Pool';
  $result = $mandrill->messages->send($message, $async, $ip_pool);

} catch(Mandrill_Error $e) {
  echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
  throw $e;
}

youtube

查詢單一影片資訊

https://gdata.youtube.com/feeds/api/videos/0dJO0HyE8xE?v=2&alt=json
https://gdata.youtube.com/feeds/api/videos/0dJO0HyE8xE?v=2&alt=json&fields=media:group(media:content(@yt:format))
{
  "version": "1.0",
  "encoding": "UTF-8",
  "entry": {
    "xmlns": "http://www.w3.org/2005/Atom",
    "xmlns$media": "http://search.yahoo.com/mrss/",
    "xmlns$yt": "http://gdata.youtube.com/schemas/2007",
    "media$group": {
      "media$content": [
        {
          "yt$format": 1
        },
        {
          "yt$format": 6
        }
      ]
    }
  }
}

Aws S3

putObject presigened URL

<?php
try {
    $command = $this->s3_client->getCommand('PutObject', [
        'Bucket' => self::S3_BUCKET,
        'Key' => $key,
    ]);
} catch (S3Exception $e) {
    $this->errmsg = 'S3 Presign error';
    return false;
}
$request = $this->s3_client->createPresignedRequest($command, '+10 minutes');
$signedUrl = $request->getUri();

Cloudfront cli create-invalidation

# backward compatible
/usr/bin/aws --profile my-profile \
    cloudfront create-invalidation \
    --distribution-id YOUR-DIST-ID \
    --invalidation-batch '{"Paths":{"Quantity":1,"Items":["/favicon.ico"]},"CallerReference":"my-invalidation-`date +%Y%m%d%H%M%S`"}'

# new Shorthand Syntax
/usr/bin/aws --profile my-profile \
    cloudfront create-invalidation \
    --distribution-id YOUR-DIST-ID \
    --invalidation-batch "Paths={Quantity=1,Items=[/favicon.ico]},CallerReference=my-invalidation-`date +%Y%m%d%H%M%S`"
#
Clone this wiki locally