I want to add yahoo chat icon inside my website. To detect ID status (online/offline), and opening messenger tool, I've wrote the PHP codes below (given from a website). But it always returns ID is offline. Does Yahoo prevents checking status? What's the problem?
<?php
$yahoo_id = 'some_id';
$getstatus = file_get_contents('http://mail.opi.yahoo.com/online?u='.$yahoo_id.'&m=a&t=1');
switch($getstatus) {
case "00": $status = '<img src="images/yahoo_offline.png" />';
break;
case "01": $status = '<img src="images/yahoo_online.png" />';
break;
}
echo $status;
?>
Related
I'm trying to output the status of a server (online/offline) in html.
I have a PHP snippet that checks the status of the server but I need the output to be in HTML format so I can use it elsewhere on my website.
I'm running wordpress with the tablera plugin, I want to output the status (just online or offline text) in the table but it does not accept PHP, only HTML.
Edit:
This is my PHP snippet:
<?php
$array="www.php.net:80";
$fp = #fsockopen($array[0], $array[1], $errno, $errstr,1);
if(!$fp){
$status = $array[0]."==><font color=\"#FF0000\">online</font>";
}
else{
$status = $array[0]."==><font color=\"#FF0000\">offline</font>";
}
fclose($fp);
echo $status;
?>
It just needs to check if the server is online or offline, if it's online it should display 'online' if its offline, it should display 'offline'.
This script checks your server to see if the server is online or not.
<?php
if (fsockopen('www.yourwebsite.com', 80)) {
echo('Reports Online');
} else {
echo('Reports Offline');
}
?>
I am trying to display images from this instagram account https://www.instagram.com/nasa/ .....into my website. I can display content from my own instagram account just fine by doing
<?php
$instagram_access_token = 'instagram access token';
$instagram_account_id = 'instagram account id'; // works fine with my account id
$call = file_get_contents('https://api.instagram.com/v1/users/'.$instagram_account_id.'/media/recent/?access_token='.$instagram_access_token);
$obj = json_decode($call)->data;
for( $i = 0; $i < sizeof($obj); $i++){
echo "<div class='instagram-image-class'>";
$img = $obj[$i]->images->standard_resolution->url;
echo '<img alt="'.$obj[$i]->caption->text.'" src="' . $img . '"/>';
if($obj[$i]->caption){
echo '<div class="instagram-image-caption">' .$obj[$i]->caption->text. '</div>';
}
echo "</div>";
};
?>
But the moment I try another account ID it doesn't work any more. Trying to understand what am I missing
It could be one of 2 reasons:
If you are in sandbox mode, you will only get your and your sandbox user's posts in API response. Once you go live mode, all data will be API response. More info on sandbox mode: https://www.instagram.com/developer/sandbox/
If you are in live mode and not seeing data from other users, then you may not have authenticated using public_content scope during oauth2. More info on login permissions: https://www.instagram.com/developer/authorization/
I'm trying to use the steam web API to show the current status of ONE steam user if he is (online,away,offline,looking to trade) etc and have setup a PHP switch as follows:
<?
$status = $steamprofile['personastate'];
switch($status) {
case 0:
echo "offline!";
break;
case 1:
echo "online!";
break;
case 2:
echo "Busy.";
break;
case 3:
echo "Away.";
break;
case 4:
echo "Snooze.";
break;
case 5:
echo "Looking to trade.";
break;
case 6:
echo "Looking to play.";
break;
default:
echo "Unknown status";
}
echo $status;
?>
It works great but only shows the user status when logged unto the site and not simply when the user is online/away/offline etc on the steam platform.
I'm wondering if anyone know how to fix so it displays the current user status on steam, not just if he/she is logged in on the website.
I've made a simple PHP script for checking Google Analytics code on given web page (i.e. I want to simply test if client has GA installed at all):
if (isset($_GET['given_domain']))
{
$domain = $_GET['given_domain'];
if (!is_valid_domain_name($domain))
{
$content = "_gaq.push";
$content_tag = "script";
set_time_limit(0);
$doc = new DOMDocument();
#$doc->loadHTMLFile($domain);
$found = false;
foreach($doc->getElementsByTagName($content_tag) as $tag) {
if (strpos($tag->nodeValue, $content) !== false) {
$found = true;
break;
}
}
if ($found == true) echo '<span style="background: green;">'.$domain.'</span>: GA found'; else echo '<span style="background: red;">'.$domain.'</span>: GA NOT found!';
}
else
echo ("Enter domain");
}
It works correctly on:
http://fivepaths.com (Found)
http://www.ebay.com (NOT found)
...
But when I try this, it gives me FOUND, but when I open the HTML code and try to CTRL+F "gaq" there is nothing.
Where is the problem?
i had found that the google analytics on the above mentioned url is coming from the js file
http://www.hezkycesky.com/sites/all/modules/google_analytics/googleanalytics.js?munwaf
I am planning to integrate a Google Checkout payment system on a social networking website. The idea is that members can buy "tokens" for real money (which are sort of the website currency) and then they can buy access to some extra content on the website etc.
What I want to do is create a Google Checkout button that takes a member to the checkout page where he pays with his credit or debit card. What I want is the Google Checkout to notify notify my server whether the purchase of tokens was successful (if the credit/debit card was charged) so I can update the local database.
The website is coded in PHP/MySQL.
I have downloaded the sample PHP code from here: code.google.com/p/google-checkout-php-sample-code/wiki/Documentation
I know how to create a Google checkout button and I have also placed the responsehandlerdemo.php file on my server. This is the file the Google Checkout is supposed to send response to (of course I set the path to the file in Google merchant account).
Now in the response handler file there is a switch block with several case statements. Which one means that the payment was successful and I can add tokens to the member account in the local database?
switch ($root) {
case "request-received": {
break;
}
case "error": {
break;
}
case "diagnosis": {
break;
}
case "checkout-redirect": {
break;
}
case "merchant-calculation-callback": {
// Create the results and send it
$merchant_calc = new GoogleMerchantCalculations($currency);
// Loop through the list of address ids from the callback
$addresses = get_arr_result($data[$root]['calculate']['addresses']['anonymous-address']);
foreach($addresses as $curr_address) {
$curr_id = $curr_address['id'];
$country = $curr_address['country-code']['VALUE'];
$city = $curr_address['city']['VALUE'];
$region = $curr_address['region']['VALUE'];
$postal_code = $curr_address['postal-code']['VALUE'];
// Loop through each shipping method if merchant-calculated shipping
// support is to be provided
if(isset($data[$root]['calculate']['shipping'])) {
$shipping = get_arr_result($data[$root]['calculate']['shipping']['method']);
foreach($shipping as $curr_ship) {
$name = $curr_ship['name'];
//Compute the price for this shipping method and address id
$price = 12; // Modify this to get the actual price
$shippable = "true"; // Modify this as required
$merchant_result = new GoogleResult($curr_id);
$merchant_result->SetShippingDetails($name, $price, $shippable);
if($data[$root]['calculate']['tax']['VALUE'] == "true") {
//Compute tax for this address id and shipping type
$amount = 15; // Modify this to the actual tax value
$merchant_result->SetTaxDetails($amount);
}
if(isset($data[$root]['calculate']['merchant-code-strings']
['merchant-code-string'])) {
$codes = get_arr_result($data[$root]['calculate']['merchant-code-strings']
['merchant-code-string']);
foreach($codes as $curr_code) {
//Update this data as required to set whether the coupon is valid, the code and the amount
$coupons = new GoogleCoupons("true", $curr_code['code'], 5, "test2");
$merchant_result->AddCoupons($coupons);
}
}
$merchant_calc->AddResult($merchant_result);
}
} else {
$merchant_result = new GoogleResult($curr_id);
if($data[$root]['calculate']['tax']['VALUE'] == "true") {
//Compute tax for this address id and shipping type
$amount = 15; // Modify this to the actual tax value
$merchant_result->SetTaxDetails($amount);
}
$codes = get_arr_result($data[$root]['calculate']['merchant-code-strings']
['merchant-code-string']);
foreach($codes as $curr_code) {
//Update this data as required to set whether the coupon is valid, the code and the amount
$coupons = new GoogleCoupons("true", $curr_code['code'], 5, "test2");
$merchant_result->AddCoupons($coupons);
}
$merchant_calc->AddResult($merchant_result);
}
}
$Gresponse->ProcessMerchantCalculations($merchant_calc);
break;
}
case "new-order-notification": {
$Gresponse->SendAck();
break;
}
case "order-state-change-notification": {
$Gresponse->SendAck();
$new_financial_state = $data[$root]['new-financial-order-state']['VALUE'];
$new_fulfillment_order = $data[$root]['new-fulfillment-order-state']['VALUE'];
switch($new_financial_state) {
case 'REVIEWING': {
break;
}
case 'CHARGEABLE': {
//$Grequest->SendProcessOrder($data[$root]['google-order-number']['VALUE']);
//$Grequest->SendChargeOrder($data[$root]['google-order-number']['VALUE'],'');
break;
}
case 'CHARGING': {
break;
}
case 'CHARGED': {
break;
}
case 'PAYMENT_DECLINED': {
break;
}
case 'CANCELLED': {
break;
}
case 'CANCELLED_BY_GOOGLE': {
//$Grequest->SendBuyerMessage($data[$root]['google-order-number']['VALUE'],
// "Sorry, your order is cancelled by Google", true);
break;
}
default:
break;
}
switch($new_fulfillment_order) {
case 'NEW': {
break;
}
case 'PROCESSING': {
break;
}
case 'DELIVERED': {
break;
}
case 'WILL_NOT_DELIVER': {
break;
}
default:
break;
}
break;
}
case "charge-amount-notification": {
//$Grequest->SendDeliverOrder($data[$root]['google-order-number']['VALUE'],
// <carrier>, <tracking-number>, <send-email>);
//$Grequest->SendArchiveOrder($data[$root]['google-order-number']['VALUE'] );
$Gresponse->SendAck();
break;
}
case "chargeback-amount-notification": {
$Gresponse->SendAck();
break;
}
case "refund-amount-notification": {
$Gresponse->SendAck();
break;
}
case "risk-information-notification": {
$Gresponse->SendAck();
break;
}
default:
$Gresponse->SendBadRequestStatus("Invalid or not supported Message");
break;
}
I guess that case 'CHARGED' is the one, am I right?
Second question, do I need an SSL certificate to receive response from Google Checkout? According to this I do: groups.google.com/group/google-checkout-api-php/browse_thread/thread/10ce55177281c2b0
But I don's see it mentioned anywhere in the official documentation.
Thank you.
I integrated this into my site over 6 months ago. It's very low volume, but works good so far.
The first thing that you should worry about is 'CHARGEABLE'. This means that the credit card has been approved for the transaction, but it will not actually charge the funds until you take action. In order to send the charge request, simply un-comment the two lines under CHARGEABLE. You can change your settings to make it automatically charge the card in 'settings' > 'preferences', but you might as well just un-comment the 2 lines and leave your options open.
Note that you might want to WAIT for the 'risk-information-notification' and determine if the risk check passed before approving the charge ($data[$root]['risk-information']['eligible-for-protection']['VALUE']). Although, seems you are talking about digital goods the possibility of chargebacks might not matter to you.
At some point, I'm sure you should also check that the request has sufficient information for you to link the funds to some account before you charge it, but maybe this is just my paranoia.
The other state that I use is 'charge-amount-notification'. It's completely possible that there is a way to use 'CHARGED', but I don't that 'CHARGED' provides an amount that was actually charged. ($amount_charged = $data[$root]['total-charge-amount']['VALUE'];)
As for the SSL, if you check the location where you enter the callback URL it states the following:
"Specify a URL for Google to notify you of new orders and changes in order state. You must provide the URL of a server running 128-bit SSLv3 or TLS"
Answer to your comment:
I do this under 'new_order_notification', not sure if you can do it elsewhere.
$items = get_arr_result( $data[$root]['shopping-cart']['items']['item'] );
foreach( $items as $item ) {
if( !isset ( $item['merchant-item-id']['VALUE'] ) ) {
//error
return;
}
$request_item_id = $item['merchant-item-id']['VALUE'];
//save your item id with corresponding google order id for further processing
}
Yes, "Chargeable" is the first thing you need to look at in a Google Checkout order. When you click "Chargeable", a window will pop up for you to actually charge the order BUT be sure that the "Eligible for Protection" is True before actually charging the order. This ensure you that the payment is covered by Google payment guarantee. You can actually see it in the "Buyer Credit Verification" section in Google Checkout.