This is their sample I don't know how to get it working.
http://aws.amazon.com/code/AWIS/402
It keeps showing: Usage: $argv[0] ACCESS_KEY_ID SECRET_ACCESS_KEY site\n
It is not working, when you fill in:
$urlInfo = new UrlInfo("myaccessKeyId", "mysecretAccessKey", "stackoverflow.com");
How do I fix this issue?
public function UrlInfo($accessKeyId, $secretAccessKey, $site) {
$this->accessKeyId = $accessKeyId;
$this->secretAccessKey = $secretAccessKey;
$this->site = $site;
}
/**
* Get site info from AWIS.
*/
public function getUrlInfo() {
$queryParams = $this->buildQueryParams();
$sig = $this->generateSignature($queryParams);
$url = 'http://' . self::$ServiceHost . '/?' . $queryParams .
'&Signature=' . $sig;
$ret = self::makeRequest($url);
echo "\nResults for " . $this->site .":\n\n";
self::parseResponse($ret);
}
The script is meant to be run from the command line like so:
php urlinfo.php ACCESS_KEY_ID SECRET_ACCESS_KEY site
It's in the readme. If you just want to use the class, you should take out the stuff after line 122 in the php file.
Related
I have a success to download a repository from github via file_get_content but what is the orientation with curl.
The advantage with the file_get_content it's like anonymous. In this case inside a backoffice, it's possible to download plugin in for example.
But Github restrict this usage at less 10 times, after the user must to wait long time to restart something.
It seems if the curl is used, github allow more access to download a respository.
Do you have an example to use with curl (like anonymous)?
Below an example that I make. It's works fine but it's not possible to use this several times. Think less 10 times.
Thank you
public function __construct() {
$this->githubUrl = 'https://github.com';
$this->githubApi = 'https://api.github.com';
$this->githubRepo = 'repos';
$this->context = stream_context_create(array('http' => array('header' => 'User-Agent: ClicShopping',)));
$this->githubRepoClicShoppingCore = 'CoreofApplication';
$this->githubRepoName = 'addOnNameOfApplication';
}
private function getGithubRepo() {
$url = $this->githubApi . '/' . $this->githubRepo . '/' . $this->githubRepoName;
return $url;
}
private function getGithubCoreRepo() {
$url = $this->githubApi . '/' . $this->githubRepo . '/' . $this->coreName . '/' . $this->githubRepoClicShoppingCore;
return $url;
}
private function setContext() {
return $this->context;
}
private function getGithubApiClicShoppingCoreArchive() {
$url = $this->githubUrl . '/' .$this->coreName . '/' . $this->githubRepoClicShoppingCore.'/archive/master.zip';
return $url;
}
Thank you.
when i use sendMessage() method to send message in chat when i am using telegram bot in group automatically reply last message
how can i solve this?
[enter image description here][1]
function Start($obj_tblTemp, $Token) {
$Keyboard = array(
'keyboard' => array(
array(INSERT_EXPENSE, DELETE_EXPENSE),
array(EXPENSE_SITUATION, RULES_AND_HELP),
array(CANCEL)
)
);
$Key_board = json_encode($Keyboard);
$url = 'https://api.telegram.org/bot' . $Token . '/sendMessage?text='. $obj_tblTemp->get_message() . '&chat_id=' . $obj_tblTemp->get_chat_Id() . '&reply_markup=' . $Key_board;
file_get_contents($url);
}
also above problem exist in below function:
function InsertExpenseMode($obj_tblTemp, $Token, $con, $obj_tblTempLatestSession) {
if ($obj_tblTemp->get_message() == INSERT_EXPENSE) {
$url = 'https://api.telegram.org/bot' . $Token . '/sendMessage?text='
. INSERT_EXPENSE_INSTRUCTION . '&chat_id=' . $obj_tblTemp->get_chat_Id();
file_get_contents($url);
} else {
if (is_numeric($obj_tblTemp->get_message()) && $obj_tblTemp->get_message() > 0) {
$url = 'https://api.telegram.org/bot' . $Token . '/sendMessage?text='
. $obj_tblTemp->get_message() . '&chat_id=' . $obj_tblTemp->get_chat_Id();
file_get_contents($url);
} else {
$url = 'https://api.telegram.org/bot' . $Token . '/sendMessage?text='
. NUMERAL_FAIL . '&chat_id=' . $obj_tblTemp->get_chat_Id();
file_get_contents($url);
}
}
}
actually i send class objects to these function and want to evaluate user inputs then insert them to database, but development wasn't completed yet.
I can get data from the Trello API using this:
private function get_card_info($card_id) {
$client = new \GuzzleHttp\Client();
$base = $this->endpoint . $card_id;
$params = "?key=" . $this->api_key . "&token=" . $this->token;
$cardURL = $base . $params;
$membersURL = $base . "/members" . $params;
$attachmentsURL = $base . "/attachments" . $params;
$response = $client->get($cardURL);
$this->card_info['card'] = json_decode($response->getBody()->getContents());
$response = $client->get($membersURL);
$this->card_info['members'] = json_decode($response->getBody()->getContents());
$response = $client->get($attachmentsURL);
$this->card_info['attachments'] = json_decode($response->getBody()->getContents());
}
However, this is broken into three calls. Is there a way to get card information, the member information, and the attachment information all in one call? The docs mention using &fields=name,id, but that only seems to limit what's returned from the base call to the cards endpoint.
It's absurd to have to hit the API 3 times every time I need card information, but I can't find any examples gathering all that's needed.
Try hitting the API with following parameters:
/cards/[id]?fields=name,idList&members=true&member_fields=all&& attachments=true&&attachment_fields=all
Trello replied to me, and stated that they would have answered much like Vladimir did. However, the only response I got from that was the initial card data, sans attachments and members. However, they also directed me to this blog post that covers batching requests. They apparently removed it from the docs because of the confusion it created.
To summarize the changes, you essentially make a call to /batch, and append a urls GET parameter with a comma separated list of endpoints to hit. The working final version ended up looking like this:
private function get_card_info($card_id) {
$client = new \GuzzleHttp\Client();
$params = "&key=" . $this->api_key . "&token=" . $this->token;
$cardURL = "/cards/" . $card_id;
$members = "/cards/" . $card_id . "/members";
$attachmentsURL = "/cards/" . $card_id . "/attachments";
$urls = $this->endpoint . implode(',', [$cardURL, $members, $attachmentsURL]) . $params;
$response = $client->get($urls);
$this->card = json_decode($response->getBody()->getContents(), true);
}
I'm trying to use the Gigya's Comment Notification functionality and I've followed the guidelines at:
http://developers.gigya.com/010_Developer_Guide/18_Plugins/022_Comments_Version_2/Comment_Notifications
I've developed the following code:
<?php
require_once('GSSDK.php');
$event = $_POST['event'];
$eventData = $_POST['eventData'];
$nonce = $_POST['nonce'];
$timestamp = $_POST['timestamp'];
$signature = $_POST['signature'];
$signatureBase = sprintf("%s_%s_%s_%s", $event, $eventData, $nonce, $timestamp);
$expectedSignature = SigUtils::calcSignature(
$signatureBase,
MY_SECRET_KEY);
if($signature !== $expectedSignature) {
header('HTTP/1.0 403 Forbidden');
die();
}
//Some other stuff
exit();
?>
But it never gets to the "//Some other stuff" part.
Always the expected signature differs from the signature provided by the Gigya's server.
What am I doing wrong?
Try the following code instead:
<?php
static function calcSignature($baseString,$key)
{
$baseString = utf8_encode($baseString);
$rawHmac = hash_hmac("sha1", utf8_encode($baseString), base64_decode($key), true);
$sig = base64_encode($rawHmac);
return $sig;
}
function checkSignature()
{
$event = $_POST["event"];
$eventData = $_POST["eventData"];
$nonce = $_POST["nonce"];
$timestamp = $_POST["timestamp"];
$signature = $_POST["signature"];
$signatureBase = $event . "_" . $eventData . "_" . $nonce . "_" . $timestamp;
$secret = "[your gigya secret key]";
$expectedSignature = calcSignature($signatureBase, $secret);
// Now compare the expectedSignature value to the signature value returned in the callback
if ($signature !== $expectedSignature)
{
header('HTTP/1.0 403 Forbidden');
die();
}
}
checkSignature();
//Some other stuff
exit();
?>
This code removes the dependency on GigyaSDK just to check the signature. The method provided is the same method that the GigyaSDK uses, but the advantage here is that this is a much smaller memory footprint since the entire GigyaSDK does not need to be loaded.
Additionally, I'm not sure if it was intentional, but your comparison has the code:
if(!$signature !== $expectedSignature) {
Instead of:
if ($signature !== $expectedSignature) {
I'm not quite sure what the purpose of the extraneous logical-NOT operator on $signature is supposed to accomplish, but it seems like this would cause unexpected behavior.
I'm getting error:
Fatal error: Method name must be a string in C:\xampp\htdocs\index.php on line 15"
LINE 15:
$obj = new $url[0]();
CODE:
<?php
error_reporting(E_ALL ^ E_NOTICE);
$url = $_GET['url'];
$url = explode('/', $url);
if (!file_exists('controllers/' . $url[0] . '.php')) {
$url[0] = 'error'; // error kontroleris
}
require 'controllers/' . $url[0] . '.php';
$obj = new $url[0]();
$obj->$url[1]();
BTW.: Script is not finished yet.
Actually, this syntax:
$urls = array('DOMDocument');
$dom = new $urls[0]('');
var_dump( $dom );
... is valid even in PHP 5.2 (proof). But this line...
$obj->$url[1]();
... is pretty damn able (another proof) to throw exactly the same error as you've shown, as you don't check for url array length anywhere in your code.
$_GET['url'] = 'foo/bar'; // temp set $_GET
$url = $_GET['url'];
$url = explode('/', $url);
if (file_exists('controllers/' . $url[0] . '.php')){
require 'controllers/' . $url[0] . '.php';
}else{
$url[0] = 'error';
}
$obj = new URL;
if(method_exists($obj,$url[0])){ // test that method exists
echo $obj->$url[0](); // or whatever your handling may be
}
class URL{
public function error(){
$return = 'this is for the error handling';
return $return;
}
}