Im trying to file_get_contents from a website but it outputs strange characters like ��}�r�H��ߙ�y��M���n�'2I��"�^ÏjI-[D������T��8�w��|��-Y
<?
echo file_get_contents("http://mp3yum.top");
?>
Is there any way to scrape some content from this site.
You need to use the CURL before calling to the external source.
$data = get_url('http://mp3yum.top');
echo($data);
function get_url($url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($curl);
curl_close($curl);
return $data;
}
Output Screen:
Related
My application use logic for work with current recipient with EchoSign (change recipient).
I need to be able retrieve current recipient for envelope usign DocuSign API. How it possible?
You should start with the DocuSign Developer Center which is a great resource for anything API related. If you go through the Quick Start section of the dev center you will see the API TOOLS section, which has free code samples that show you how to do things like Get Recipient Status.
API TOOLS
API DOCUMENTATION
The API Walkthroughs have an example of how to get the current recipient status. Here is the full PHP sample:
<?php
// Input your info here:
$email = "***"; // your account email
$password = "***"; // your account password
$integratorKey = "***"; // your account integrator key, found on (Preferences -> API page)
// copy the envelopeId from an existing envelope in your account that you want to query:
$envelopeId = 'cbe279f6-199c-.................';
// construct the authentication header:
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 1 - Login (retrieves baseUrl and accountId)
/////////////////////////////////////////////////////////////////////////////////////////////////
$url = "https://demo.docusign.net/restapi/v2/login_information";
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo "error calling webservice, status is:" . $status;
exit(-1);
}
$response = json_decode($json_response, true);
$accountId = $response["loginAccounts"][0]["accountId"];
$baseUrl = $response["loginAccounts"][0]["baseUrl"];
curl_close($curl);
//--- display results
echo "\naccountId = " . $accountId . "\nbaseUrl = " . $baseUrl . "\n";
/////////////////////////////////////////////////////////////////////////////////////////////////
// STEP 2 - Get envelope information
/////////////////////////////////////////////////////////////////////////////////////////////////
$data_string = json_encode($data);
$curl = curl_init($baseUrl . "/envelopes/" . $envelopeId . "/recipients" );
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
"X-DocuSign-Authentication: $header" )
);
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ( $status != 200 ) {
echo "error calling webservice, status is:" . $status . "\nError text --> ";
print_r($json_response); echo "\n";
exit(-1);
}
$response = json_decode($json_response, true);
//--- display results
echo "First signer = " . $response["signers"][0]["name"] . "\n";
echo "First Signer's email = " . $response["signers"][0]["email"] . "\n";
echo "Signing status = " . $response["signers"][0]["status"] . "\n\n";
?>
I have a basic php script that gets my last 30 instagram pictures. It just uses the media/recent endpoint url.. That works fine.
Looks like this
$userid = "ID";
$accessToken = "ACCESSTOKEN";
// Gets data
function fetchData($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
// Pulls and parses data.
$result = fetchData("https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}&count=30");
$result = json_decode($result);
And echo the output like this:
<?= $post->images->standard_resolution->url ?>
But how can I put the endpoint url's in a array and be able to echo comments and likes in the same way..
I've tried using instaphp, but it's really slow and creates an access token for each visit..
If you have the full result set, you should be able to get things this way:
Likes:
<?= $post->likes->count ?>
<?= $post->likes->data->username ?>
<?= $post->likes->data->full_name ?>
<?= $post->likes->data->id ?>
<?= $post->likes->data->profile_picture ?>
Comments:
<?= $post->comments->count ?>
etc
Check out the documentation for the response: http://instagram.com/developer/endpoints/users/#get_users_media_recent
I am running phpmailer and very much new to it.
Problem definition: Not able to see php variables data in the received email while html content can seen properly.
Below is some of the code:
require 'PHPMailer/class.phpmailer.php';
$mail = new PHPMailer;
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->IsHTML(true); // Set email format to HTML
$mail->Subject = 'Message';
$mail->Body = '<body>
<div align="center"><p7><strong>HELLO WORLD</strong></p7></div>
<h9><u>Details</u></h9><br/>
<h9><strong>NAME:</strong> <?php echo "$name";?> <?php echo "$place";?>
</body>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->Send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
Not able to see data defined under php.
Also $name and $place is the dynamic data for the every mail.
Please help.
You cannot put php statements in single quotes. use the following instead:
$mail->Body = '<body>
<div align="center"><p7><strong>HELLO WORLD</strong></p7></div>
<h9><u>Details</u></h9><br/>
<h9><strong>NAME:</strong>' . $name . ' ' . $place . '
</body>';
You need to put the text between " instead of '.
PHP only replaces variables in double quoted strings.
Also you shouldn't use php code in the strings.
$mail->Body = "
<body>
<div align=\"center\"><p7><strong>HELLO WORLD</strong></p7></div>
<h9><u>Details</u></h9><br/>
<h9><strong>NAME:</strong> $name $place
</body>
";
try instead :
$mail->Body = "<body>
<div align=\"center\"><p7><strong>HELLO WORLD</strong></p7></div>
<h9><u>Details</u></h9><br/>
<h9><strong>NAME:</strong>$name $place
</body>";
You don't have to put php tags in your string since you are already in a php context !
Replace Body with :
$mail->Body = '<body>
<div align="center"><p7><strong>HELLO WORLD</strong></p7></div>
<h9><u>Details</u></h9><br/>
<h9><strong>NAME:</strong>'.$name.' '.$place.'</body>';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message .= "Phone: 0181-4606260.<br>";
$message .="Mobile :09417608422.<br>";
Send_Mail('abc#example.com','Welcome',$message,$headers);
try this...
I am trying to send a html email via mail(), however gmail just displays the email as plain text, no mark up, eg:
mail("blah#blah.com", "<i>Italic Text</i>");
just appears as
<i>Italic Text</i>
Any ideas?
Have you set your email headers?
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
If yes, do any other email clients have the same problem? Or is it just Gmail?
Try it with css, the i tag is deprecated, not sure if that is causing it...
<span style='font-style:italic;'>Italic Text</span>
Or you could try using the em tag:
<em>Italic Text</em>.
How to send HTML email in drupal 6 using drupal_mail ? How can I change HTML header to show email contents in HTML.
You can to set the header in hook_mail_alter()
<?php
hook_mail_alter(&$message) {
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
}
?>
i know this may be late, but it may help others. Its better to use drupal_mail and then set the headers in hook_mail instead of hook_mail alter. an example would be like:
/*drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE)
Lets say we call drupal_mail from somewhere in our code*/
$params = array(
'subject' => t('Client Requests Quote'),
'body' => t("Body of the email goes here"),
);
drupal_mail("samplemail", "samplemail_html_mail", "admin#mysite.com", language_default(), $params, "admin#mysite.com");
/*We now setup our mail format, etc in hook mail*/
function hook_mail($key, &$message, $params)
{
case 'samplemail_html_mail':
/*
* Emails with this key will be HTML emails,
* we therefore cannot use drupal default headers, but set our own headers
*/
/*
* $vars required even if not used to get $language in there since t takes in: t($string, $args = array(), $langcode = NULL) */
$message['subject'] = t($params['subject'], $var, $language->language);
/* the email body is here, inside the $message array */
$body = "<html><body>
<h2>HTML Email Sample with Drupal</h2>
<hr /><br /><br />
{$params['body']}
</body></html>";
$message['body'][] = $body;
$message['headers']['Content-Type'] = 'text/html; charset=UTF-8; format=flowed';
break;
}
If this is unclear to you, a complete tutorial on this can be found on My Blog
Hope this helps
JK