FarrisFahad 103 Junior Poster

I want to post Pins using Pinterest API. I have tried to generate code using ChatGPT but it returns an error.

Here is my code so far ...

<?php

$clientId = "xxx"; // Replace with your App ID
$clientSecret = "xxx"; // Replace with your App Secret
$redirectUri = "xxx"; // Must match the one used earlier
$authCode = "xxx"; // Paste the code from the URL

// Pinterest API token endpoint
$tokenUrl = "https://api.pinterest.com/v5/oauth/token";

$postFields = [
    'grant_type' => 'authorization_code',
    'code' => $authCode,
    'redirect_uri' => $redirectUri,
    'continuous_refresh' => true
];

$authHeader = base64_encode("$clientId:$clientSecret");

$ch = curl_init($tokenUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
   'Content-Type: application/json',
   'Authorization: Basic ' . $authHeader
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);

if ($response === false) {
    die("cURL Error: " . htmlspecialchars($error));
}

$data = json_decode($response, true);

// Error handling for HTTP response
if ($httpCode !== 200) {
    die("Pinterest API Error: HTTP $httpCode - " . htmlspecialchars($response));
}

// Error handling for API response
if (!isset($data['access_token'])) {
    die("Error: Invalid response from Pinterest API. Full response: " . json_encode($data, JSON_PRETTY_PRINT));
}

// Successfully received access token
$accessToken = $data['access_token'];
echo "Access Token: " . htmlspecialchars($accessToken);

?>

Here is the error message I am getting ...

Failed to create pin. Response: {"code":2,"message":"Authentication failed.","status":"failure"}

I tried many things but it always return an error.

Here is the docs page: https://developers.pinterest.com/docs/api/v5/oauth-token

Is there something I am missing?

Any help would be appreciated.

FarrisFahad 103 Junior Poster

I am having a problem understanding the following ...

I am an okay web developer. I am not great. But I want to make money from my skills.
Having said that, when I go to websites like Freelancer to search for a project to work on everyone is asking for an exceptional developer and they pay very little. I don't know how are average joey's make it in this business.

What is your take on this?

rproffitt commented: From what I've read from you, you are above average. +17
FarrisFahad 103 Junior Poster

Hey, I know that this discussion is old but I need to know now.
I am new to OOP in PHP. Is it good to call a class within a class? Why or why not?
How should I create an object? I want objects to use other methods from other objects.
Your example is good ...

class A
{
    private $obj; 

    public function __construct()
    {
        $this->obj = new B();
    }
}

class B
{
    private $obj;

    public function __construct()
    {
        $this->obj = new C();
    }
}

class C
{
    private $obj;

    public function __construct()
    {
        $this->obj = new A();
    }
}

$obj = new C();

but I am trying to do the following ...

class A
{
    private $A;
    private $B;
    private $C;

    public function __construct()
    {
        $this->A = new A();
        $this->B = new B();
        $this->C = new C();
    }
}

class B
{
    private $A;
    private $B;
    private $C;

    public function __construct()
    {
        $this->A = new A();
        $this->B = new B();
        $this->C = new C();
    }
}

class C
{
    private $A;
    private $B;
    private $C;

    public function __construct()
    {
        $this->A = new A();
        $this->B = new B();
        $this->C = new C();
    }
}

$A = new A();
$B = new B();
$C = new C();
FarrisFahad 103 Junior Poster

How can I include objects in each other using PHP OOP?

I have 3 classes all classes make use of one another. I am trying to call them on __construct but it's creating an infinite calls to one another. How can I solve this?

FarrisFahad 103 Junior Poster

I want to write an SEO load more button that Google crawls and click on. I have read somewhere in the documents that Google will only click on anchor tags with href value. My current website loads content using a button and I have noticed after changing some, not load more, links Google started to index my website.

Is there a best practice method to do this?
Will it index more pages on my site?

I am not sure if I should post this in SEO or Web Development section :)

FarrisFahad 103 Junior Poster

For people who used both and build websites with both, which one is better? Why?

FarrisFahad 103 Junior Poster

I want to write 1,000 blog posts on my blog. I want to sell ReviewMyLink for $1,000 USD on Flippa and I want to make PicturePunches much better.

Happy new year :)

What about you?

bijutoha commented: Which toolset would you use to write a thousand blogs? +3
FarrisFahad 103 Junior Poster

Do you use Google as a search engine? Are you considering switching to something like Bing or DuckDuckGo?
Do you feel like the search results is no longer helpful? Why?

FarrisFahad 103 Junior Poster

I have a memes site that users can earn from. I want to make the website easier to use and more fun.
What should I do to make the website better?
Website: PicturePunches

DGPickett commented: It might be good to sort logs by user and see if they had to click a lot to get where they wanted to go. Intuitive is nice but you need to sample! +4
FarrisFahad 103 Junior Poster

Hi, I am using JS in my website to load more content. I have buttons or input type button as my load more content.
I am worried that Google won't index the content behind the load more button because it's a button and not an anchor tag.

Here is what I am currently using ...

<div class="MORE">
  <button onclick="loadMore(this, '.Memes', 'ex/more.memes.php');">Load More Content</button>
</div>

I believe there is a better way to do it. Can you help?

Also here is my JS ...

function loadMore(elm, content, ajax){

    let id = document.getElementById('id').innerText;
    let section = document.getElementById('section').innerText;
    let subsection = document.getElementById('subsection').innerText;
    let time = document.getElementById('time').innerText;
    let offset = document.querySelectorAll(content).length;

    elm.innerText = "Loading ...";

    let formData = new FormData();
    let xhr = new XMLHttpRequest();

    xhr.onreadystatechange = function(){

        if(this.readyState == 4 && this.status == 200){

            if(this.responseText){

                document.getElementById('append-a').innerHTML += this.responseText;

                impression();

                elm.innerText = "Load More";

            }else{

                elm.innerText = "No More";

            }

        }

    };

    formData.append("id", id);
    formData.append("section", section);
    formData.append("subsection", subsection);
    formData.append("time", time);
    formData.append("offset", offset);

    xhr.open('POST', ajax, true);
    xhr.send(formData);

}
FarrisFahad 103 Junior Poster

I have a memes website and I want to drive traffic from social media. I have a Facebook page with 20,000+ fans but when I post I hardly get any traffic.
I also tried Pinterest but most users just bounce off the website, although it can drive a good amount of traffic.
I haven't tried Twitter and Instagram and that is because I am mainly focusing on desktop traffic.

What social network should I condition or recondition to drive traffic? I want to work with one?

digitalstalk commented: use facebook ads with reach option +0
johnlee90 commented: You should try mobile too, +0
paulmisunday commented: Facebook activity and paid advertisement. +0
FarrisFahad 103 Junior Poster

Hello, I am trying to redirect my website from desktop version to mobile version.

Here is the desktop version example:
http://www.example.com

Here is what I have accomplished:
http://m.example.com

The problem is that some files are stored under the www version and I want them to be shown on the m version like javascript and images.

Any help would be much appreciated.

Here is my code:

RewriteEngine on
RewriteBase /

RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTP_HOST} ^example.xyz [NC]
RewriteRule ^(.*)$ http://www.example.xyz/$1 [L,R=301,NC]

RewriteCond %{HTTP_USER_AGENT} android|avantgo|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|opera\ m(ob|in)i|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ (ce|phone)|xda|xiino [NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a\ wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r\ |s\ )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1\ u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp(\ i|ip)|hs\-c|ht(c(\-|\ |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac(\ |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt(\ |\/)|klon|kpt\ |kwc\-|kyo(c|k)|le(no|xi)|lg(\ g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-|\ |o|v)|zz)|mt(50|p1|v\ )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v\ )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-|\ )|webc|whit|wi(g\ |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-) [NC]
RewriteRule ^$ http://m.example.xyz [R,L]

RewriteRule ^(categories|collections|about|contact)$ $1.php [NC,L]

RewriteRule ^picture/([\d]+)$ picture.php?id=$1 [NC,L]
RewriteRule ^category/([-\w]+)$ category.php?category=$1 [NC,L]
RewriteRule ^collection/([-\w]+)$ collection.php?collection=$1 [NC,L]
FarrisFahad 103 Junior Poster

I just think it's more neat.

FarrisFahad 103 Junior Poster

I want to add a Facebook share button on my website. But I don't want the new window pop up dialog. I want the dialog that opens on the website, just like Facebook has.

I want to accomplish this:

2014-01-21_19_35_19-Feed_and_Share_Dialog.png

Instead of this:

ajXTj.png

Can anyone point to me a resource?

michaelsmith commented: I am looking for this +0
FarrisFahad 103 Junior Poster

You don't have to do SEO if you have valuable content. Bad content requires consistent SEO, while great content markets it self.

When I say great content I mean great user experience. Was the user satisfied with the page he or she visited? Did they get what they want? Are they coming back? These are all things you should consider.

And no, you don't need to do SEO continuasely.

I heard a great quote from Income School channel on YouTube ...

If you are gonna put hours of work into SEO. You would be better off optimizing and improving your content.

You know, links aren't everything to Google. They look into user behavior too.

Just my 2 cents. :)

rproffitt commented: "Bad content requires consistent SEO" +15
FarrisFahad 103 Junior Poster

Thanks a lot @jkon for this helpful information. I will need to look more into it.

FarrisFahad 103 Junior Poster

Thank you the second article helped, Sorry I guess I was looking for something simpler than link 1.

pty commented: I'm glad it helped +9
FarrisFahad 103 Junior Poster

You still don't understand the question. I already have a website similar to 9Gag, but I want to replicate their voting system. I don't know the algorythm. I don't want to build a clone site like 9Gag. But thank you for your reply.

rproffitt commented: That's a good question. Most likely secret sauce. Or in those scripts you buy. +15
FarrisFahad 103 Junior Poster

My funny pictures website has an advertising system that is basic. I want to improve it to attract more advertisers.

Currently you only need a 728px by 90px a image, a link and your bid. The higher the bid the faster the results and the cost is obviously higher.

It's very simple. I don't get a lot of hits now, but when I do I want to be ready. Can you help me come up with great ideas for advertisers?

Here is what I came up with ...

  1. Make ads like PTC websites where users earn for clicks.
  2. People can review websites that are advertising, so that the advertiser gets feedback for his website.

Do you have any other ideas?

FarrisFahad 103 Junior Poster

I read about a lot of people who ranked their site without building a single link. Does posting great content or building a great site can get you ranked higher? What if I'm in a competitive niche, do I need to build links? Or should I post my content to Social Media and wait for links to be built?

logan_paul commented: Yup its true you can rank your website just by writing unique article. Its all about user intent. If the intent is good he will read the content. +0
optimiserteam commented: yeah,it can be possible when your article's unique and done a best On page seo +0
coolgear commented: Website may rank in google but not for long run. For stability in Google one must create high authority backlinks. +0
jstech001 commented: yes it is possible but it takes alot of time +0
FarrisFahad 103 Junior Poster

Hi Dani,

My website offer the visitor the ability to make money from uploading pictures, well funny pictures. The funnier you are the more money you'll make. And that is done by picture and ad impressions. The more subscribers you have the more money you'll make. What did you understand when you first visited the website? What was your first impression?

rprofitt,

Are you saying that it may take 5 years to build an audience? If so, why does it take 5 years? How do most Facebook pages get their fans? I don't buy fans, I advertise to get them, so there are no fake fans.

To all,

I recently found an interesting method, and that is boosting posts. From boosting posts I get engagement, fans, and traffic to my site. But at a low level. I am waiting for my posts to go viral. I haven't had any viral posts yet. So this means I don't know the result, but I think it's gonna be good.

rproffitt commented: Did you try a few good images on Imgur and Reddit? +12
FarrisFahad 103 Junior Poster

I am a web developer and I have built many websites. And over the years my designs is getting better but now I can't seem to figure out how to be better in design. I don't know how to draw but I have a somewhat good selection in color combination for a website.

My question is ... How do I get better in design?
It seems like I have the following options:

  • Look for great websites on the web and see what they are doing.
  • Try to copy great looking websites.
  • Play around with some designs and try to figure out how to do it better.

If you have any advice please tell me.

Thanks,
Farris

Jen Larosa commented: I'd totally recommend to just have a minimal design, and search for color palette regarding with the niche of your site. +0
FarrisFahad 103 Junior Poster

I have found great plugin that works perfectly it's called, waypoint. You can search for it using Google
Here is a link to the plugin: http://imakewebthings.com/waypoints/
Just follow the guide on the website, easy and simple.
If you are having problems search through Stackoverflow using keyword: jquery waypoint

cereal commented: thanks for sharing! +14
FarrisFahad 103 Junior Poster

For anybody who is still struggling ...
Here is what I have understood:

  1. The request type which is equal to Notify Validate, which means we want to validate that the notifaction came from PayPal.

    // Notify command
    $request = "cmd=_notify-validate";

  2. Prepare the URL to send back to PayPal to get a validation of the notification.

    foreach ($_POST as $key => $value){
    if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()){
    $value = urlencode(stripslashes($value));
    }else{
    $value = urlencode($value);
    }
    $request .= "&$key=$value";
    }

  3. Send the URL through cURL to connect to PayPal and get a response for either "VERIFIED" or "INVALID"

    // Initial cURL
    $ch = curl_init();
    // Set opt
    curl_setopt($ch,CURLOPT_URL,"https://www.sandbox.paypal.com/cgi-bin/webscr");
    //curl_setopt($ch,CURLOPT_URL,"https://www.paypal.com");
    curl_setopt($ch,CURLOPT_POST,true);
    curl_setopt($ch,CURLOPT_POSTFIELDS,$request);
    curl_setopt($ch,CURLOPT_FOLLOWLOCATION,false);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
    // Return result
    $result = curl_exec($ch);
    // Close cURL connection
    curl_close($ch);

  4. If the response was Verified now you know that the notifaction was from PayPal and you can start processing.
    ** Note: All the POST variables are available just write $_POST['payment_status'] and you will get the value
    I didn't know that until now.

cereal commented: thanks for sharing! +14
FarrisFahad 103 Junior Poster

I have solved the problem, I named one of the MySQL Colums update which was making a problem :) . I renamed the Colums from update to update_something and it worked, Yay :)

Thank you guys for your help :)